if time is so small in series so how plot the figure

2 visualizaciones (últimos 30 días)
a(1)=1;
b(1)=1;
c(1)=1;
s1=0;
s2=0;
s3=0;
k3=2.8;
k1=0.33;
k2=1;
T=0.1;
t=0:0.01:0.1;
tau=0:0.1:1
tau=zeros(length(t));
for i=1:20
a(i+1)=(1/(i+1)).*(b(i)-a(i))*k2;
b(i+1)=(1/(i+1)).*(a(i).*(k3-c(i))-b(i));
c(i+1)=(1/(i+1))*(a(i).*b(i)-k1*c(i));
s1=s1+(a(i).*tau.^i);
s2=s2+(b(i).*tau.^i);
s3=s3+(c(i).*tau.^i);
disp([s1 s2 s3])
end
tau=0:0.1:1;
so how to plot the graph between tau =t/T where range of tau will be 0 to 1 ie tau=[0 1]; so the range of t=0 to 0.1
so pl plot the graph between plot(t,s1,t,s2,t,s3)

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Mzo. de 2022
a(1)=1;
b(1)=1;
c(1)=1;
s1=0;
s2=0;
s3=0;
k3=2.8;
k1=0.33;
k2=1;
T=0.1;
t=0:0.01:0.1;
tau = t ./ T;
%tau=zeros(length(t));
for i=1:20
a(i+1)=(1/(i+1)).*(b(i)-a(i))*k2;
b(i+1)=(1/(i+1)).*(a(i).*(k3-c(i))-b(i));
c(i+1)=(1/(i+1))*(a(i).*b(i)-k1*c(i));
s1=s1+(a(i).*tau.^i);
s2=s2+(b(i).*tau.^i);
s3=s3+(c(i).*tau.^i);
disp([s1;s2;s3])
end
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 0 0.1040 0.2160 0.3360 0.4640 0.6000 0.7440 0.8960 1.0560 1.2240 1.4000 0 0.1033 0.2134 0.3301 0.4536 0.5837 0.7206 0.8642 1.0144 1.1713 1.3350 0 0.1001 0.2011 0.3036 0.4085 0.5167 0.6288 0.7457 0.8683 0.9972 1.1333 0 0.1039 0.2149 0.3324 0.4555 0.5833 0.7152 0.8503 0.9877 1.1268 1.2667 0 0.1033 0.2131 0.3292 0.4512 0.5791 0.7126 0.8515 0.9955 1.1445 1.2981 0 0.1001 0.2010 0.3031 0.4068 0.5125 0.6202 0.7297 0.8410 0.9535 1.0667 0 0.1039 0.2151 0.3334 0.4587 0.5913 0.7318 0.8810 1.0401 1.2107 1.3946 0 0.1033 0.2131 0.3291 0.4512 0.5791 0.7125 0.8512 0.9950 1.1436 1.2967 0 0.1001 0.2010 0.3032 0.4072 0.5137 0.6232 0.7363 0.8537 0.9764 1.1056 0 0.1039 0.2151 0.3333 0.4581 0.5894 0.7269 0.8704 1.0195 1.1736 1.3316 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9944 1.1426 1.2951 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6224 0.7343 0.8493 0.9674 1.0886 0 0.1039 0.2151 0.3333 0.4582 0.5898 0.7282 0.8738 1.0270 1.1888 1.3603 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6226 0.7348 0.8506 0.9705 1.0951 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7279 0.8729 1.0247 1.1836 1.3494 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9696 1.0929 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8731 1.0253 1.1851 1.3530 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8504 0.9698 1.0936 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1847 1.3520 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0934 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3523 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948 0 0.1001 0.2010 0.3031 0.4072 0.5135 0.6225 0.7347 0.8503 0.9698 1.0935 0 0.1039 0.2151 0.3333 0.4582 0.5897 0.7280 0.8730 1.0252 1.1848 1.3522 0 0.1033 0.2131 0.3291 0.4512 0.5790 0.7123 0.8509 0.9943 1.1424 1.2948
plot(t, s1, t, s2, t, s3)
  6 comentarios
Walter Roberson
Walter Roberson el 3 de Mzo. de 2022
Your values are exploding.
The graphs show log10 of the absolute values. (The values are alternating signs in practice.)
Notice that the values are headed up past 10^200. At i = 18 b and c both become infinite (that is, they overflow.)
format long g
a(1)=0;
b(1)=1;
c(1)=0;
s1=0;
s2=0;
s3=0;
k3=28;
k1=8/3;
k2=10;
T=0.1;
t=0:0.01:1;
tau = t ./ T;
%tau=zeros(length(t));
for i=1:20
a(i+1)=(1/(i+1)).*(b(i)-a(i))*k2;
b(i+1)=(1/(i+1)).*(a(i).*T*(k3-c(i))-b(i));
c(i+1)=(1/(i+1))*(T*a(i).*b(i)-k1*c(i));
if ~all(isfinite([a,b,c]),'all')
subplot(3,1,1); plot(abs(log10(a))); title('log10(abs(a))')
subplot(3,1,2); plot(abs(log10(b))); title('log10(abs(b))');
subplot(3,1,3); plot(abs(log10(c))); title('log10(abs(c))');
disp(a)
disp(b)
disp(c)
error('first loop broke at i = %d', i);
end
end
Columns 1 through 8 0 5 -18.3333333333333 57.9166666666667 -143.993055555556 302.906732253086 -589.673053242846 1361.77375688499 Columns 9 through 16 -5443.7221870296 59759.4445958811 -2657740.90196883 1334719063.94102 -26494588512488.9 2.59714098213512e+20 -4.46136840954973e+31 7.44623873661128e+49 Columns 17 through 19 -1.90047778234547e+79 8.083893319598e+126 -7.86387214278258e+203
Columns 1 through 8 1 -0.5 4.83333333333333 -14.0798611111111 37.7509837962963 -109.864405016906 499.745952265149 -3537.57621144164 Columns 9 through 16 54315.7224088515 -2863755.54756983 1599005135.82725 -34441630347171.6 3.63599711004329e+20 -6.69205261429863e+31 1.1913981978578e+50 -3.2308122299873e+79 Columns 17 through 19 1.45510079752764e+127 -1.49413570712869e+204 Inf
Columns 1 through 8 0 0 -0.0833333333333333 -2.15972222222222 -15.1573206018518 -83.8614048501265 -443.462339789482 -3535.76323904447 Columns 9 through 16 -52478.7936446002 -2942802.68684416 -1555072420.38937 -35414165694570.3 -3.53614612870783e+20 -6.8810176616501e+31 -1.15868027327996e+50 -3.32204142694831e+79 Columns 17 through 19 -1.41514112809699e+127 -1.5363259648747e+204 -Inf
first loop broke at i = 18
for i=1:20
s1=s1+(a(i).*tau.^i);
s2=s2+(b(i).*tau.^i);
s3=s3+(c(i).*tau.^i);
disp([s1;s2;s3])
if any(any(isnan([s1,s2,s3])))
error('second loop broke at i = %d', i);
end
end
plot(tau, s1, tau, s2, tau, s3)
Walter Roberson
Walter Roberson el 3 de Mzo. de 2022
And your s values are over 10^300 and 10^500
format long g
a(1) = sym(0);
b(1) = sym(1);
c(1) = sym(0);
s1 = sym(0);
s2 = sym(0);
s3 = sym(0);
k3=28;
k1=8/3;
k2=10;
T=0.1;
t=0:0.01:1;
tau = t ./ T;
%tau=zeros(length(t));
for i=1:20
a(i+1)=(1/sym(i+1)).*(b(i)-a(i))*k2;
b(i+1)=(1/sym(i+1)).*(a(i).*T*(k3-c(i))-b(i));
c(i+1)=(1/sym(i+1))*(T*a(i).*b(i)-k1*c(i));
if ~all(isfinite([a,b,c]),'all')
subplot(3,1,1); plot(abs(log10(a))); title('log10(abs(a))')
subplot(3,1,2); plot(abs(log10(b))); title('log10(abs(b))');
subplot(3,1,3); plot(abs(log10(c))); title('log10(abs(c))');
disp(a)
disp(b)
disp(c)
error('first loop broke at i = %d', i);
end
end
for i=1:20
s1=s1+(a(i).*tau.^i);
s2=s2+(b(i).*tau.^i);
s3=s3+(c(i).*tau.^i);
if ~all(isfinite([s1,s2,s3]),'all')
disp(s1)
disp(s2)
disp(s3)
error('second loop broke at i = %d', i);
end
end
plot(tau, s1, tau, s2, tau, s3);
title('original');
legend({'s1', 's2', 's3'});
plot(tau, log10(abs(s1)), tau, log10(abs(s2)), tau, log10(abs(s3)));
title('log10(abs(s))');
legend({'s1', 's2', 's3'});

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by