フィルターのクリア

How to plot a surface 3d plot using this function?

1 回表示 (過去 30 日間)
fremond khoo
fremond khoo 2012 年 9 月 3 日
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 :)

採用された回答

Star Strider
Star Strider 2012 年 9 月 3 日
編集済み: Star Strider 2012 年 9 月 3 日
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 件のコメント
fremond khoo
fremond khoo 2012 年 9 月 3 日
Thanks a lot :) it helps greatly :)
Star Strider
Star Strider 2012 年 9 月 3 日
It is my pleasure to help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by