Why does semilogy plot on a linear scale Matlab R2016a?

9 views (last 30 days)
I have multiple files in a folder that I want to plot waterfall style on a semi-logaritmic scale.
A very simplified version of my code is this:
FileList=dir(Folder);
FileList = FileList(~[FileList.isdir]); %remove directories, will be ordered according to name
figure()
hold on
for l = 1:numel(FileList) %every file itself
temp=importdata(strcat(Folder,'\',FileList(l).name),'\t');
%In my real code I modify the data here, namely stiching of segments of the graphs.
Log=(temp(:,2)./max(temp(:,2))).*(0.4.^l);
semilogy(temp(:,1),Log)
end
title(FolderList(i).name)
xlabel('Energy (eV)')
ylabel('Intensity (au)')
hold off
In the output the data has the values I want for the waterfall plot, but y-axis is not logaritmic. I do not get any error message and I have similar code where these is no problem. Any ideas what could be going wrong?
  1 Comment
Adam
Adam on 7 Feb 2017
Edited: Adam on 7 Feb 2017
semilogy seems to do what I expect in Matlab R2016b, but I obviously can't repeat your code as I don't have your data. Is it working correctly for simpler data that doesn't involve all the file loading?
Be careful with calling things 'Log'. 'log' is a fundamental builtin function and whilst using a capital letter should mean you don't clash with this I still wouldn't recommend it. Matlab is a bit odd in my experience as to when it cares about capitalisation and when it doesn't. e.g. on my machine:
>> which log
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\elfun\@double\log) % double method
>> which Log
C:\Program Files\MATLAB\R2016b\toolbox\distcomp\parallel\@codistributed\log.m % codistributed method
Both of the files pointed to their appear to use a lower-case 'l' so it isn't immediately obvious to me why they are picked up differently by the which command, but if I name a variable 'Log' then it will hide that second function:
>> Log = 7;
>> which Log
Log is a variable.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Feb 2017
The "hold on" that you start out with locks in the axes scale as normal instead of log. You need to specifically set the axes scale to log if you have hold on in effect.

More Answers (0)

Categories

Find more on Exponents and Logarithms 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!