How can I plot multiple iteration loglog graphs.

3 views (last 30 days)
N0 = 1*10.^9;
n = 3;
T=365*24*3600;
Table = cell(n, 4);
t = logspace(1, 7);
A = logspace(-22,-1);
ylabel('Activity /s^.-1');
xlabel('t');
set(gca,'xscale','log')
L(1) = 4.979*10.^-18;
L(2) = 3.329*10.^-7;
L(3) = 2.874*10.^-5;
for i=2:n
Bsum=0;
for t = 1:1*10.^5:T
Prod1 = 1;
for l = 1:i-1
Prod1 = Prod1*L(l);
end
for j = 1:i
Prod2 = 1;
for k = 1:i t
if k ~= j
Prod2 = Prod2*(L(k) - L(j));
end
end
Sum = Ssum+exp(-L(j)*t)/Prod2;
end
F = Sum*Prod1*N0;
A = Sum*L(i);
Table(i, :) = {i t F A };
fprintf('%d %d %d %d\n', Table{i, :, :});
end
end
My Scipt needs to output graphs for each iteration of i in terms of A against t, at the moment it will do it to i=3 but if I need to more I would like it to automatically plot the graphs like the subplot command.
Currently my code for my graph only outptus the whole of the iteration from 1:3 rather than each iteration
Activity = logspace(-22,-1);
loglog(A,t,'-o')
line(A, t)
Any help will be great!

Accepted Answer

Sindhu Karri
Sindhu Karri on 27 Mar 2020
You can try using nexttile which is similar to subplot
By using nexttile, loglog inside the for loopyou will be able to plot the graph of (A,t) for each iteration.
Refer to the below link:
  1 Comment
Alex Manuel
Alex Manuel on 28 Mar 2020
I've run into a problem where only my last value is used, how would I go about plotting each A at each t step for a specific iteration?
i t A Sum
3 310 8.251044e-09 2.371350e-13
3 311 8.330961e-09 2.394318e-13
3 312 8.411392e-09 2.417434e-13
3 313 8.492338e-09 2.440698e-13
3 314 8.573802e-09 2.464111e-13
3 315 8.655785e-09 2.487673e-13
3 316 8.738288e-09 2.511384e-13
It looks like this, where only the very last value is used on the graph.
i t A Sum
3 316 8.738288e-09 2.511384e-13

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!