some meshgrid and matlab.chart.graphics errors
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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);
0 Kommentare
Antworten (2)
Steven Lord
am 5 Dez. 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
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.
Walter Roberson
am 5 Dez. 2020
Bearbeitet: Walter Roberson
am 5 Dez. 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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!