Why does semilogy plot on a linear scale Matlab R2016a?
古いコメントを表示
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 件のコメント
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Exponents and Logarithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!