blank plot with out value
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
a(1)=1;
b(1)=1;
c(1)=1;
s1=0;
s2=0;
s3=0;
k3=28;
k1=8/3;
k2=10;
t=1:20;
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));
end
for i=1:20
s1=s1+(a(i).*t.^i);
s2=s2+(b(i).*t.^i);
s3=s3+(c(i).*t.^i);
end
plot(t,s1)
pl you are req to plot the plot between t vs s1 may be data overflow so how to remove it
2 commentaires
David Hill
le 28 Fév 2022
Describe the equations you are trying to plot. Current equations are going to inf and result in nan values in s1.
Réponses (2)
Image Analyst
le 28 Fév 2022
I think you mean s1 vs. t. If so, maybe this is what you want:
a(1)=1;
b(1)=1;
c(1)=1;
s1=0;
s2=0;
s3=0;
k3=28;
k1=8/3;
k2=10;
t=1:20;
for k=1:20
a(k+1)=(1/k+1)*(b(k)-a(k))*k2;
b(k+1)=(1/(k+1))*(a(k)*(k3-c(k))-b(k));
c(k+1)=(1/(k+1))*(a(k)*b(k)-k1*c(k));
end
% Now make t (currently 20 long) the same length (21) as "a":
t = 1 : length(a);
for k=1: length(a)
s1(k+1) = s1(k) + (a(k) .* t(k) .^ k);
s2 = s2 + (b(k) .* t(k) .^ k);
s3 = s3 + (c(k) .* t(k) .^ k);
end
% Now make t (currently 22 long) the same length (22) as s1:
t = 1 : length(s1);
% Now plot
plot(t, s1, 'b-', 'LineWidth', 2)
grid on;
xlabel('t');
ylabel('s1')
Walter Roberson
le 28 Fév 2022
You can remove that problem by using the symbolic toolbox for the calculations.
This will not be fast, but at least you will get some value instead of inf or nan. The values will probably reach the order of 10^26000 .
3 commentaires
Walter Roberson
le 28 Fév 2022
Original plot is blank because every value is so far out of range that it cannot be plotted. The second shows the log10 of the data -- it is obviously trending to the order of -10^5000
Reminder: your role is to show you things like the below, how to get extended range. Our role is not to do your research for you or examine papers to come up with the correct equations for you. We help you understand MATLAB; we mostly do not help you to understand the science or mathematics.
N = 20;
a = sym(zeros(N+1,1));
b = sym(zeros(N+1,1));
c = sym(zeros(N+1,1));
a(1) = 1;
b(1) = 1;
c(1) = 1;
s1 = sym(0);
s2 = sym(0);
s3 = sym(0);
k3 = sym(28);
k1 = sym(8)/3;
k2 = sym(10);
t = sym(1:N+1).';
for i=1:N
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));
end
for i=1:N
s1=s1+(a(i).*t.^i);
s2=s2+(b(i).*t.^i);
s3=s3+(c(i).*t.^i);
end
s1
vpa(s1)
subplot(2,1,1);
plot(double(t), double(s1)); title('original')
subplot(2,1,2);
plot(double(t), double(log10(-s1))); title('log10')
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!