Using the 'Surf' command for variable 'x' values
1 view (last 30 days)
Show older comments
Siddharth Gopujkar
on 22 Mar 2019
Commented: Star Strider
on 23 Mar 2019
I am trying to use the Surf command. Here's the data that I have:
x= [1.158633 4.871195 7.667851 11.45038 22.11895
1.221922 3.777088 7.641091 11.52413 21.89302
1.52861 4.609719 7.60228 12.06438 21.33681
1.934019 6.881875 9.591649 13.51807 21.30859 ];
y=[0 12.5 25 37.5];
[xx, yy]=meshgrid(x, y)
zz=[ 0.000522 0.000549 0.000557 0.000623 0.000222
0.000584 0.000476 0.000566 0.00062 0.000194
0.000557 0.000528 0.00065 0.000594 0.000144
0.000603 0.000514 0.000588 0.000606 0.000206 ];
The problem is, the 'y' value is the same for every 4 points in the zz matrix but the x value differs. Because of that, surf doesn't work. If all x values were something like [1.5 5 8 12 21], it would work perfectly. But they differ a little. Any suggestions what I can do?
0 Comments
Accepted Answer
Star Strider
on 23 Mar 2019
It doesn’t work because ‘y’ is a vector.
Try this:
x= [1.158633 4.871195 7.667851 11.45038 22.11895
1.221922 3.777088 7.641091 11.52413 21.89302
1.52861 4.609719 7.60228 12.06438 21.33681
1.934019 6.881875 9.591649 13.51807 21.30859 ];
y=[0 12.5 25 37.5];
yy = repmat(y, size(x,2), 1)';
zz=[ 0.000522 0.000549 0.000557 0.000623 0.000222
0.000584 0.000476 0.000566 0.00062 0.000194
0.000557 0.000528 0.00065 0.000594 0.000144
0.000603 0.000514 0.000588 0.000606 0.000206 ];
figure
surf(x, yy, zz)
grid on
2 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!