As far as I understand the way to 3-d plot/ surface plot is "meshgrid". But the data I have has a specific format:
X | Y | Z |
---|---|---|
1 | 0.1 | 10 |
1 | 0.2 | 12 |
1 | 0.3 | 13 |
2 | 0.1 | 11 |
2 | 0.2 | 12 |
2 | 0.3 | 14 |
3 | 0.1 | 11 |
3 | 0.2 | 12 |
3 | 0.3 | 15 |
The first and second column (X and Y) repeat themselves in that fashion, and I need to plot Z(X,Y).
How Do I do it?
CodePudding user response:
X = 1:1:3 % grid can be set by beginning:step:end
Y = 0.1:0.1:0.3
[x,y] = meshgrid(X,Y); % then make 2d domain
% z values have to be done manually or can automate if you read your data from txt file
z = [10 12 13; 11 12 14; 11 12 15];
% and finally
surf(x,y,z)