# blank plot with out value

1 view (last 30 days)
shiv gaur on 28 Feb 2022
Commented: Image Analyst on 28 Feb 2022
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 CommentsShowHide 1 older comment
shiv gaur on 28 Feb 2022
this is lorenz equation which is change in power series a b c from x y z
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));

Image Analyst on 28 Feb 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') Image Analyst on 28 Feb 2022

Walter Roberson on 28 Feb 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 .
Walter Roberson on 28 Feb 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
s1 = vpa(s1)
ans = subplot(2,1,1);
plot(double(t), double(s1)); title('original')
subplot(2,1,2);
plot(double(t), double(log10(-s1))); title('log10') R2021b

### Community Treasure Hunt

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

Start Hunting!