What Does this error even mean??

[x, y, z]=meshgrid(0.5:0.05:0.5, 0.5:0.05:0.5, 0.5:0.05:0.5);
a=0;
for l=1:length(x)
for j=1:length(y)
for k=1:length(z)
a(l, j, k)=k-sqrt((0.25)-((0.58-(l).^2))-((0.58-(j).^2)));
end
end
end
surf(x,z,a)
*Error using surf (line 75)
Z must be a matrix, not a scalar or vector*

Answers (1)

The way you have defined x y and z, they are each just a single number (i.e. a "scalar").
I think maybe you meant
[x, y, z]=meshgrid(-0.5:0.05:0.5, -0.5:0.05:0.5, -0.5:0.05:0.5);
I still get an error from your code when I make that replacement, but I am not quite sure what you intended. I suggest you give
doc surf
a careful read.

1 Comment

Dear 'The Cyclist', Thank you for your reply. I actually forgot to put the -signs. I managed to get results correcting it as follows;
[x, y]=meshgrid(-1:0.05:1, -1:0.05:1);
for l=1:length(x) for j=1:length(y) a(l, j)=0.5-sqrt((0.58-((0.35-(l).^2))-((0.35-(j).^2)))); end end
surf(x, y, a)
and also for the 2d mesh,
[x, y]=meshgrid(-1:0.05:1, -1:0.05:1);
for l=1:length(x) for j=1:length(y) a(l, j)=0.5-sqrt((0.58-((0.35-(l).^2))-((0.35-(j).^2)))); end end
plot(x, a) hold on plot(y, a)
What I am actually doing is plotting in 2D and 3D the area covered by an end-effector and the height spanned by the carriage as the arm go up and down in a reprap delta robot (transnational)
I surely can use some help on the inverse kinematics visualization of similar machine on Matlab.
Thank you

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 20 Oct 2013

Commented:

on 20 Oct 2013

Community Treasure Hunt

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

Start Hunting!