Why does semilogy plot on a linear scale Matlab R2016a?

14 次查看(过去 30 天)
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 个评论
Adam
Adam 2017-2-7
编辑:Adam 2017-2-7
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.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2017-2-7
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Exponents and Logarithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by