필터 지우기
필터 지우기

why range of x axis of time is not showing

조회 수: 2 (최근 30일)
shiv gaur
shiv gaur 2022년 3월 9일
댓글: Walter Roberson 2022년 3월 15일
Tstart = 0.0;
Tend = 100.0;
Nt = 2000;
dT = (Tend-Tstart)/Nt;
X0 = 1;
Y0 = 2;
Z0 = 3;
N = 20;
k1=1
k2=3
k3=1
k4=5
I=0.5
s=4;
xr=-1.6;
r=0.0001;
% Initialize coefficient arrays
T = zeros(Nt+1,1);
X = zeros(Nt+1,1);
Y = zeros(Nt+1,1);
Z = zeros(Nt+1,1);
a = zeros(N+1,1);
b = zeros(N+1,1);
c = zeros(N+1,1);
T(1) = 0.0;
X(1) = X0;
Y(1) = Y0;
Z(1) = Z0;
for j = 2:Nt+1
a(1) = X(j-1);
b(1) = Y(j-1);
c(1) = Z(j-1);
for k = 1:N
a(k+1)=(b(k)-k1*a(k).^3+k2*a(k).^2-c(k)+I)/(k+1);
b(k+1)=(k3-k4*a(k).^2-b(k))/(k+1);
c(k+1)=r*(s*(a(k)-xr)-c(k))/(k+1);
end
x = a(1);
y = b(1);
z = c(1);
for k = 2:N+1
x = x + a(k)*dT^(k-1);
y = y + b(k)*dT^(k-1);
z = z + c(k)*dT^(k-1);
end
T(j) = T(j-1) + dT;
X(j) = x;
Y(j) = y;
Z(j) = z;
end
figure(1)
plot(T,X,'Color','red')
hold on
figure(2)
plot(T,Y,'Color','red')
hold on
figure(3)
plot(T,Z,'Color','red')
hold on
figure(4)
plot3(X,Y,Z,'Color','red')
hold on
the time range is coming 1.5 in
place of 100
  댓글 수: 1
Rik
Rik 2022년 3월 9일
Serious question: why do you refuse to use formatting?

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2022년 3월 9일
Because after that your values go to infinity or nan. Automatic selection of plot axes range is based only on the finite coordinates of what is drawn.
  댓글 수: 2
shiv gaur
shiv gaur 2022년 3월 9일
편집: Walter Roberson 2022년 3월 9일
why other type is showing time value on x axis
Tstart = 0.0;
Tend = 1000.0;
Nt = 20000;
dT = (Tend-Tstart)/Nt;
X0 = 0.0;
Y0 = 1.0;
Z0 = 0.0;
N = 20;
SIGMA = 10;
R = 28;
B = 8/3;
%
% Initialize coefficient arrays
T = zeros(Nt+1,1);
X = zeros(Nt+1,1);
Y = zeros(Nt+1,1);
Z = zeros(Nt+1,1);
a = zeros(N+1,1);
b = zeros(N+1,1);
c = zeros(N+1,1);
T(1) = 0.0;
X(1) = X0;
Y(1) = Y0;
Z(1) = Z0;
for j = 2:Nt+1
% Compute Taylor coefficients
a(1) = X(j-1);
b(1) = Y(j-1);
c(1) = Z(j-1);
for k = 1:N
SB = 0.0;
SC = 0.0;
for i= 0:k-1
SB = SB + a(i+1)*c(k-i);
SC = SC + a(i+1)*b(k-i);
end
a(k+1) = (SIGMA*(b(k) - a(k)))/k;
b(k+1) = ((R*a(k) - b(k)) - SB)/k ;
c(k+1) = (-B*c(k) + SC)/k ;
end
x = a(1);
y = b(1);
z = c(1);
for k = 2:N+1
x = x + a(k)*dT^(k-1);
y = y + b(k)*dT^(k-1);
z = z + c(k)*dT^(k-1);
end
% Prepare for T = T + dT
T(j) = T(j-1) + dT;
X(j) = x;
Y(j) = y;
Z(j) = z;
end
figure(1)
plot(T,X,'Color','red')
hold on
figure(2)
plot(T,Y,'Color','red')
hold on
figure(3)
plot(T,Z,'Color','red')
hold on
shiv gaur
shiv gaur 2022년 3월 9일
pl resolve this problem for time rannge

댓글을 달려면 로그인하십시오.


Davide Masiello
Davide Masiello 2022년 3월 9일
That's happening because all the values of X,Y, and Z after T = 1.5 are NaN, which will not be plotted by MatLab.
I guess there might be a mistake in your equations that causes them to predict your variables to be NaN.
  댓글 수: 12
Walter Roberson
Walter Roberson 2022년 3월 15일
I had my program continue calculatign with symbolic Y0.
Before the end of the 7th j loop, some of the expressions involve Y0 to the power of over 320000, and coefficients over 10 to the million.
The arithmetic round-off involved in the calculations is horrible.
If your Y0 is anything with absolute value greater than 1 then for certain your values would explode beyond the range of double precision; if your Y0 is anything with absolute value less than 1, then most of the terms are going to underflow.
Walter Roberson
Walter Roberson 2022년 3월 15일
I substituted in 10^-10 for Y0 in c(6) . The result was less than -2 times 10 to the one million.
There is just no possibility of getting useful numbers out of the equations you have given.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by