How can I set the z axis for this plot? It changes with every iteration regardless of what the axis function tells it to do.
clear all
clear
clc
x = linspace(0,2,30); %x data points
y = linspace(0,3,20); %y data points
[xgrid,ygrid] = meshgrid(x,y); %create grid of all x and y points
m=1;
n=1;
figure(3)
axis square
box on
grid on
t= linspace(0,5,50);
for k = 1:50
axis([0 2 0 3 -5 5])
animate = (576/(pi^6)).*((((1+((-1).^(m+1))).*(1+((-1).^(n+1))))/(m.^3.*n.^3)).*sin((m.*pi.*xgrid)/2).*sin((m.*pi.*ygrid)/3).*cos(pi.*t(k).*(sqrt(9.*(m.^2)+4.*(n.^2)))));
surf(xgrid,ygrid,animate);
pause(0.01);
colormap jet
box on
axis([0 2 0 3 -5 5])
end

 採用された回答

KSSV
KSSV 2017 年 5 月 29 日

1 投票

You limit the z-axes to certain limit. Imagine what would be the maximum and minimum limits of z and then limit it.
add:
zlim([-3 3])
after surf in your code, now z is limited to 3 and -3. It will not change.

1 件のコメント

Elitt Noguera
Elitt Noguera 2017 年 5 月 29 日
You sir are a genius and I appreciate the help! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2017 年 5 月 29 日

コメント済み:

2017 年 5 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by