why range of x axis of time is not showing
2 ビュー (過去 30 日間)
古いコメントを表示
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
回答 (2 件)
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 件のコメント
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
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
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!