How to get a line plot without markers, on a logarithmic scale in a for loop?
3 views (last 30 days)
Show older comments
I want to express my reuslts from a for loop on a logaritmic scale (on x-axis). However, I am having trouble in getting both the logarithmic displays and line plots in one go.
- With the semilogx: display in logarithmic scale is achieved but only if I identify a marker such as 'o' or 's'. However, I can't get it to plot show the results as a line or a line plot.
- With the addpoints approach: Sure, I get a line plot. Still, in this case I am unable to solve the other problem of displaying on a logarithmic scale.
To keep the script brief, I am leaving out the constants I used. You can put in random values for execution. This is my for loop:
t=1:10000;
for i=1:numel(t)
f2=(v293/v)^(10*(alpha^4));
f1=1+((1-alpha)^2)*log(350/Blaine);
n=nzero*f1*f2;
etaalpha=exp(-n*alpha);
Aalpha=k*(A/((k*alphau)+alpha))*(alphau-alpha);
alpha=Aalpha*etaalpha*exp(-EA/(R*T))*exp(EA/(R*293))+alpha;
semilogx(i,alpha,'o-'); % outputs a logarithmic x-axis with markers (sadly not a line)
hold on
% hold all
% addpoints(h,t(i),alpha(1)) % outputs a line plot
% drawnow limitrate
end
3 Comments
dpb
on 27 Jun 2021
semilogx(i,alpha,'o-');
You told it to NOT use a line but only a marker.
See the doc for linestyle triplets for the details.
Answers (1)
Scott MacKenzie
on 27 Jun 2021
Edited: Scott MacKenzie
on 27 Jun 2021
i = 1:10;
alpha = rand(1,10);
tiledlayout('flow');
nexttile;
semilogx(i,alpha,'o-'); % your code: line+maker
nexttile;
semilogx(i,alpha); % line only (i.e., no marker)
6 Comments
Scott MacKenzie
on 1 Jul 2021
Yes, that should work, provided t and Aplot are vectors of the same length. You can also just use
semilogx(Aplot)
as noted in my previous comment.
BTW, here is the documentation on the use of semilogx when ommitting the 1st argument, X:
See Also
Categories
Find more on Annotations 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!