Surf() Question
Mostrar comentarios más antiguos
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!
Respuestas (2)
Wayne King
el 27 de Abr. de 2012
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
el 27 de Abr. de 2012
0 votos
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 comentario
Paloma
el 27 de Abr. de 2012
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!