Why does semilogy plot on a linear scale Matlab R2016a?

9 ビュー (過去 30 日間)
Irene Geijselaers
Irene Geijselaers 2017 年 2 月 7 日
コメント済み: Irene Geijselaers 2017 年 2 月 7 日
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.
  1 件のコメント
Irene Geijselaers
Irene Geijselaers 2017 年 2 月 7 日
Thank you, this worked. For future reference:
set(gca, 'YScale', 'log')
worked for me.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExponents and Logarithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by