some meshgrid and matlab.chart.graphics errors

2 visualizaciones (últimos 30 días)
Hamid Reza N.D
Hamid Reza N.D el 5 de Dic. de 2020
Editada: Walter Roberson el 5 de Dic. de 2020
Hi. i wana draw my function of three variable. this is my code and i got those Errors. what shloud i do?
>> Q=[1 2 3;4 5 6;7 8 9];
>> S=[0;1;2];
>> u1=linspace(-10,10,20);
>> u2=linspace(-10,10,20);
>> u3=linspace(-10,10,20);
>> [U1,U2,U3]=meshgrid(u1,u2,u3);
>> L=1/2*(Q(1,1)*U1.^2+(Q(1,2)+Q(1,3)+Q(2,1)+Q(2,3)+Q(3,1)+Q(3,2))*U1.*U2.*U3+Q(2,2)*U2.^2+Q(3,3)*U3.^2)+S(1)*U1+S(2)*U2+S(3)*U3;
>> meshc(U1,U2,U3,L)
Error using matlab.graphics.chart.primitive.Surface/set
Value must be a vector or 2D array of numeric type
Error in matlab.graphics.chart.internal.ctorHelper (line 8)
set(obj, pvpairs{:});
Error in matlab.graphics.chart.primitive.Surface
Error in mesh (line 143)
hh = matlab.graphics.chart.primitive.Surface('XData',x,'YData',y,'ZData',z,'CData',c,...
Error in meshc (line 58)
hm = mesh(cax, x, y, z, c);

Respuestas (2)

Steven Lord
Steven Lord el 5 de Dic. de 2020
Q=[1 2 3;4 5 6;7 8 9];
S=[0;1;2];
u1=linspace(-10,10,20);
u2=linspace(-10,10,20);
u3=linspace(-10,10,20);
[U1,U2,U3]=meshgrid(u1,u2,u3);
L=1/2*(Q(1,1)*U1.^2+(Q(1,2)+Q(1,3)+Q(2,1)+Q(2,3)+Q(3,1)+Q(3,2))*U1.*U2.*U3+Q(2,2)*U2.^2+Q(3,3)*U3.^2)+S(1)*U1+S(2)*U2+S(3)*U3;
whos U1 U2 U3 L
Name Size Bytes Class Attributes L 20x20x20 64000 double U1 20x20x20 64000 double U2 20x20x20 64000 double U3 20x20x20 64000 double
Does meshc accept 3-dimensional arrays as input? [Hint: it does not.] I think you probably want one of the volume visualization functions (https://www.mathworks.com/help/matlab/volume-visualization.html) instead.
  1 comentario
Hamid Reza N.D
Hamid Reza N.D el 5 de Dic. de 2020
meshc accepts 2-dimensional arrays. and gives me figure. but this time i have these errors how can i find that my meshc accepts 3-dimensional arrays as input?

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 5 de Dic. de 2020
Editada: Walter Roberson el 5 de Dic. de 2020
You cannot use meshc to draw a function with three independent variables and one dependent variable.
You also cannot use patch or surface for this purpose, at least not directly.
You could do a triangulation and a triangular mesh plot in which the dependent variable was represented by color https://www.mathworks.com/help/matlab/ref/trimesh.html
but with the grid being evenly spaced you are going to have trouble looking "into" the volume.

Categorías

Más información sobre Surface and Mesh 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