Converting Y-axis values to the base of 10

2 views (last 30 days)
Hi,
I have a below code which gave me a plot like what I attached:
%importing data
data_fluide = load('data_fluid_AC220.txt');
t_fluide= data_fluide_ac220(:,1);
dilution=data_fluide_ac220(:,13);
data_fluide_ac225 = load('data_fluid_AC225.txt');
t_fluide_ac225 = data_fluide_ac225(:,1);
dilution_ac225=data_fluide_ac225(:,13);
t1=t_fluide;
y1= log(dilution);
t2= t_fluide_ac225;
y2= log(dilution_ac225);
figure(1)
fitobject1 = fit(t1,y1,'poly3');
fitobject2=fit(t2,y2,'poly3');
plot (fitobject1)
hold on
plot (fitobject2)
hold off
But now I want to convert the value of Y-axis to go to the basis of 10 and my Y-axis be like 10^-6, 10^-5,....,10^0,10^1.
I tried many things but could not find a good solution. I appreciate if anyone have aan experience with this.
Thank you
Parisa

Answers (1)

Star Strider
Star Strider on 26 Nov 2022
This can be done easily using ytickformat (introduced in R2016b) —
x = linspace(0, 2.5);
y = 6*exp(-1.5*x) - 6;
figure
plot(x, y)
ytickformat('10^{%2d}') % Set Format
.

Categories

Find more on Data Type Conversion 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!