Error : Value must be a vector or 2D array of numeric type
Show older comments
I want to draw my function of two variable so that the graph gives me Z values between -5 and 5. I used this code
[X,Y,Z] = meshgrid(0:.2:1, 0:.2:1, -5:.2:5);
Z = arrayfun(@mFunction, X, Y);
surf(X,Y,Z)
but i get the following error :
Error using surf (line 57)
While setting the 'XData' property of Surface:
Value must be a vector or 2D array of numeric type
Thanks!
1 Comment
KSSV
on 6 Jul 2016
what is that mFunction? It seems the output of mFunction is not double. Post mFunction here.
Accepted Answer
More Answers (1)
Hamid Reza N.D
on 5 Dec 2020
1 vote
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);
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!