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
Wayne King 2012년 4월 27일

0 개 추천

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
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 .

댓글 수: 1

Paloma
Paloma 2012년 4월 27일
Yeah I double checked and my U and average_wait time are coming out as scalars, so I've gotta figure out where that is going wrong.
Thanks!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2012년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by