Surf() Question
古いコメントを表示
I'm trying to plot the results from an ethernet simulation, but I'm getting an error when I reach the surf() command. Everything else seems to be correct in the code.
Here is how I call the function:
%outputs
U=(frame_cntr.*10)./10000;
wt=find(waiting_time ~= -1);
ave_wait=sum(wt)./frame_cntr;
[n,p]=meshgrid(N,P);
surf(n,p,U)
surf(n,p,ave_wait)
and here is the error I'm getting:
??? Error using ==> surf at 70
Z must be a matrix, not a scalar or vector.
Error in ==> Telecomm_Main at 157
surf(n,p,U)
Any help is appreciated!
回答 (2 件)
Wayne King
2012 年 4 月 27 日
U=(frame_cntr.*10)./10000;
The above must be a vector, but in order to use surf(), this must be a matrix.
For example:
Z = randn(100,1);
surf(Z)
Will generate the exact error you are getting.
If you want a 3-D plot of a vector, you can use plot3()
Walter Roberson
2012 年 4 月 27 日
0 投票
You have not shown us any definition for N or P, so we have no idea what their sizes are relative to U. You have not given us any size hints for frame_cntr so we are not able to figure out the size of U (which would be the same as the size of frame_cntr).
Are you sure that frame_cntr is not a scalar when you run? frame_cntr would have to be a 2D matrix for everything else to work out dimensionally .
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!