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