why cant i plot graph with surf() function?
2 views (last 30 days)
Show older comments
clc;clear all;
for t=0:0.02:2
for x=0:0.1:10
U=10*sin(2*pi*(t-(x/5)))+2*sin(2*pi*(t+(x/5)))
end
end
3 Comments
Image Analyst
on 27 Nov 2014
OK, no problem then. If my answer worked, can you officially mark it as "Accepted"? Thanks in advance.
Answers (1)
Image Analyst
on 27 Nov 2014
Edited: Image Analyst
on 27 Nov 2014
You didn't index U - it's just a single number. You can either index it, or vectorize it. I show the vectorized method below:
T = 0:0.02:2;
X = 0:0.1:10;
[t, x] = meshgrid (T, X);
U=10*sin(2*pi*(t-(x/5)))+2*sin(2*pi*(t+(x/5)));
surf(U);
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots 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!