フィルターのクリア

How to Change the Exponential Scale in axis to linear scale?

9 ビュー (過去 30 日間)
Behrad Ze
Behrad Ze 2022 年 8 月 12 日
コメント済み: Behrad Ze 2022 年 8 月 12 日
Dear Experts,
I have a 3D surface which is being read from a file (one example file is attached). My X and Y axis are linear. I am converting the Y axis using a formula to Exponential type. After conversion, I want to plot the the 3D surface with the modifications. When I plot the data, the Y axis is also shown in Exponential. Now, I want to change the axis in a way to be shown as linear, without changing the Exonential data (only the view of axis). Is there any way to do that? I am using this code:
csvfiles = dir('*.csv');
for file = csvfiles'
sample=readmatrix(file.name);
x=sample(1,2:end);
y=sample(2:end,1);
dataSample=sample(2:end,2:end);
L=length(y);
Dalton=double(Dalton);
for i=1: L
Dalton(i)=8.227*exp(1)+6*exp(-7.9591*exp(1)-1*y(i));
end
figure();
graph=surf(x,Dalton,dataSample);
set(graph,'LineStyle','none');
title(file.name)
colormap('turbo');
colorbar();
end
Thank You so much for your support.
Best,
Behrad
  1 件のコメント
Behrad Ze
Behrad Ze 2022 年 8 月 12 日
Thank You so much. this was all what I was looking for :)

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

採用された回答

dpb
dpb 2022 年 8 月 12 日
Guessing at what you mean, precisely, try something like--
Dalton=8.227*exp(1)+6*exp(-7.9591*exp(1)*y); % use MATLAB vector syntax, no loop needed here
hS=surf(x,Dalton,dataSample,'linestyle','none');
[du,ia]=unique(Dalton,'stable'); % the double exponential saturates very quickly
yu=y(ia); % the y values to match
ytks=yticks; % retrieve default tick values y axis
ytks=ytks(iswithin(ytks,min(du),max(du))); % save only those within range that exists
yticks(ytks) % set the new subset on plot
yticklabels(interp1(du,uy,ytks)) % label with y that produced that Dalton on tick
The double exponential saturates very quickly as can be seen
And interp1 won't work with duplicate values on the X direction for the reverse lookup; hence the unique to retrieve all values that are numerically distinguishable.
Then, to have values that will produce a result for y, must restrict the shown tick values to be within that range.
iswithin is my handy-dandy utility routine
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by