How to plot a surface 3d plot using this function?
1 view (last 30 days)
Show older comments
TIME=1:1:100;
Z=1:1:100;
[X,Y]=meshgrid(TIME,Z);
P=12242-28.649.*cos(6.28.*TIME+1.33.*Z)-1702.3.*sin(6.28.*TIME+1.33.*Z)-495.13.*cos(12.57.*TIME+2.67*Z)+986.71.*sin(12.57.*TIME+2.67.*Z)+498.18.*cos(18.85.*TIME+4.*Z)-398.52.*sin(18.85.*TIME+4.*Z)-319.34.*cos(25.13.*TIME+5.33.*Z)+165.06.*sin(25.13.*TIME+5.33.*Z)+213.61.*cos(31.42.*TIME+6.67.*Z)-71.69.*sin(31.47.*TIME+6.67.*Z)-151.29.*cos(37.7.*TIME+8.*Z)+29.867.*sin(37.7.*TIME+8.*Z)+112.34.*cos(43.98.*TIME+9.33.*Z)-9.378.*sin(43.98.*TIME+9.33.*Z)-86.576.*cos(50.266.*TIME+10.667.*Z)-1.2438.*sin(50.266.*TIME+10.667.*Z);
surf(Z,P,TIME)
The error is always the same:
??? Error using ==> surf at 78 Z must be a matrix, not a scalar or vector.
Error in ==> signal at 5 surf(Z,P,TIME)
Can anybody help me on this?..Any help will be appreciated. THanks and have a nice day :)
1 Comment
Oleg Komarov
on 3 Sep 2012
Please format the code (only the code): http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
Accepted Answer
Star Strider
on 3 Sep 2012
Edited: Star Strider
on 3 Sep 2012
The easiest way to do what you want is to convert P into an anonymous function and pass it the correct arguments:
TIME=1:1:100;
Z=1:1:100;
[X,Y]=meshgrid(TIME,Z);
P=@(TIME,Z) 12242-28.649.*cos(6.28.*TIME+1.33.*Z)-1702.3.*sin(6.28.*TIME+1.33.*Z)-495.13.*cos(12.57.*TIME+2.67*Z)+986.71.*sin(12.57.*TIME+2.67.*Z)+498.18.*cos(18.85.*TIME+4.*Z)-398.52.*sin(18.85.*TIME+4.*Z)-319.34.*cos(25.13.*TIME+5.33.*Z)+165.06.*sin(25.13.*TIME+5.33.*Z)+213.61.*cos(31.42.*TIME+6.67.*Z)-71.69.*sin(31.47.*TIME+6.67.*Z)-151.29.*cos(37.7.*TIME+8.*Z)+29.867.*sin(37.7.*TIME+8.*Z)+112.34.*cos(43.98.*TIME+9.33.*Z)-9.378.*sin(43.98.*TIME+9.33.*Z)-86.576.*cos(50.266.*TIME+10.667.*Z)-1.2438.*sin(50.266.*TIME+10.667.*Z);
Pmtx = P(X,Y);
surfc(X,Y,Pmtx)
2 Comments
More Answers (0)
See Also
Categories
Find more on Surface and Mesh 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!