I'm trying to plot data on a 3D graph using the waterfall function. Here's some example code that isn't working properly:
x=0:.1:1;
y(1,:) = exp(x);
y(2,:) = exp(2*x);
z = [1,2];
waterfall(x,y,z);
I'm trying to plot each curve on it's own z dimension, but I'm not formatting the waterfall command properly. I think I could also use a "mesh" function, but I can't get that working either.
This is the answer
x=0:.1:1;
Z(1,:) = exp(x);
Z(2,:) = exp(2*x);
[X,Y] = meshgrid(x,1:size(Z,1));
waterfall(X,Y,Z)
I think you can use:
x=0:.1:1;
y(1,:) = exp(x);
y(2,:) = exp(2*x);
z = [1,2];
hold on
plot(x,y(1,:),z(1))
plot(x,y(2,:),z(2))
But I'm not sure if that's your desired output.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.