Borrar filtros
Borrar filtros

Using the 'Surf' command for variable 'x' values

2 visualizaciones (últimos 30 días)
Siddharth Gopujkar
Siddharth Gopujkar el 22 de Mzo. de 2019
Comentada: Star Strider el 23 de Mzo. de 2019
I am trying to use the Surf command. Here's the data that I have:
x= [1.158633 4.871195 7.667851 11.45038 22.11895
1.221922 3.777088 7.641091 11.52413 21.89302
1.52861 4.609719 7.60228 12.06438 21.33681
1.934019 6.881875 9.591649 13.51807 21.30859 ];
y=[0 12.5 25 37.5];
[xx, yy]=meshgrid(x, y)
zz=[ 0.000522 0.000549 0.000557 0.000623 0.000222
0.000584 0.000476 0.000566 0.00062 0.000194
0.000557 0.000528 0.00065 0.000594 0.000144
0.000603 0.000514 0.000588 0.000606 0.000206 ];
The problem is, the 'y' value is the same for every 4 points in the zz matrix but the x value differs. Because of that, surf doesn't work. If all x values were something like [1.5 5 8 12 21], it would work perfectly. But they differ a little. Any suggestions what I can do?

Respuesta aceptada

Star Strider
Star Strider el 23 de Mzo. de 2019
It doesn’t work because ‘y’ is a vector.
Try this:
x= [1.158633 4.871195 7.667851 11.45038 22.11895
1.221922 3.777088 7.641091 11.52413 21.89302
1.52861 4.609719 7.60228 12.06438 21.33681
1.934019 6.881875 9.591649 13.51807 21.30859 ];
y=[0 12.5 25 37.5];
yy = repmat(y, size(x,2), 1)';
zz=[ 0.000522 0.000549 0.000557 0.000623 0.000222
0.000584 0.000476 0.000566 0.00062 0.000194
0.000557 0.000528 0.00065 0.000594 0.000144
0.000603 0.000514 0.000588 0.000606 0.000206 ];
figure
surf(x, yy, zz)
grid on
  2 comentarios
Siddharth Gopujkar
Siddharth Gopujkar el 23 de Mzo. de 2019
It worked! Thank you so much! :)
Star Strider
Star Strider el 23 de Mzo. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by