error using contour z must be at least a 2x2 matrix

3 visualizaciones (últimos 30 días)
x = (pi/2):0.1:(2*pi);
y = (pi/2):0.1:(2*pi);
z = sin(x) + cos(y);
contour3(x,y,z)
I need a contour plot of x,y,z variables. How do i get it?

Respuesta aceptada

Birdman
Birdman el 14 de Feb. de 2018
Use meshgrid.
x = (pi/2):0.1:(2*pi);
y = (pi/2):0.1:(2*pi);
[X,Y]=meshgrid(x,y);
z = sin(X) + cos(Y);
contour3(X,Y,z)
  2 comentarios
Aishwarya Bangalore Kumar
Aishwarya Bangalore Kumar el 14 de Feb. de 2018
Thank you sir for the help.
Connor Fitzgerald
Connor Fitzgerald el 9 de En. de 2021
@Birdman, but why meshgrid?
My code with your implementation looks like:
plotX = app.UITablePlot.Data(:,2);
plotY = app.UITablePlot.Data(:,3);
plotZ = app.UITablePlot.Data(:,4);
[plotX2, plotY2] = meshgrid(plotX, plotY)
contour3(app.UIAxes, plotX2, plotY2, plotZ)
However I still receive the same error.

Iniciar sesión para comentar.

Más respuestas (1)

ZEESHAN AHMED
ZEESHAN AHMED el 18 de En. de 2023
How to plot contour map if I have individual data for example
  1. Torque (50001x1)
  2. speed (50001x1)
  3. efficiency(50001x13)
All of the data is taken from simulink in matrices.

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by