
Originally Posted by
CaptainBlack
Try:
Code:
x=1:30;
y=1:30;
[X,Y]=meshgrid(x,y)
Z=sin(X.*Y);
plot3(X,Y,Z);
Ty CB but I have a double sequence (I need to calculate it by iteration).
I could write the following code and it works but I wonder if I can show it as a surface or not (something like meshing but negative parts yellow and positive parts red)?
Code:
z=ones(30,30);
for x=2:30
for y=2:30
z(x,y)=power(-1,y)*z(x-1,y)+2*power(-1,x)*z(x,y-1);
end;
end;
for x=1:30
for y=1:30
if z(x,y)>0
plot3(x,y,z(x,y),'r*');
else
plot3(x,y,z(x,y),'y*');
end
grid on;hold on;
end;
end;
box on;
view(0,90);
xlabel('x');
ylabel('y');
zlabel('z'); Thanks again.