Reputation: 661
I have two variables which i sweep, W1
and W3
. I made a nested loop of these two variables.
for i=1:size(W1,2)
for j=1:size(W3,2)
d(i,j)=someexpression(W1(i),W3(j))
end
end
I want to do a 3D plot with W1
in the x-axis and W3
in the y-axis and d should be in the z-axis so that I have a 3D plot (or some contour plot).
EDIT: The 3d plot should actually be a surface
Upvotes: 0
Views: 125
Reputation: 32873
You can do the interpolation manually:
x = linspace(W1(1), W1(end), 100);
y = linspace(W2(1), W2(end), 100);
z = interp2(W1, W2, d, x, y);
surf(x, y, z)
Upvotes: 1