Adding a second scaled y-axis to a plot

4 ビュー (過去 30 日間)
Christian Nørgaard
Christian Nørgaard 2018 年 5 月 25 日
コメント済み: Ameer Hamza 2018 年 5 月 25 日
Hello,
I have been trying to figure out how to add a second scaled y-axis ( or even just a second y-axis) and even after reading through several Matlab forum posts it still does not work. I was wondering if anyone out there, would help me figure out what I am doing wrong.
My personal thoughts on what is wrong is something to do with the fact that I am trying to plot a curve fit on a set of data and when I tell Matlab to plot according to some x-axis is can not compute my request.
My matlab code so far:
x=[
0
3
6
9
11.5
13.952
];
y=[
0.905
0.900
0.850
0.800
0.788
0
];
v=[
0
3
6
9
11.5
13.952
];
p=[
0
2.5
5.1
8.9
11.493
0
];
f=fit(v,p,'poly5')
c=fit(x,y,'exp2')
figure(1)
plot(f)
figure(2)
x= 0: 1.0 : 15;
plot(f);
hold on;
plot(c)
Where x,y are plots for one curve and v,p (x and y coordinates respectivly) for the other curve
I have tried,
x= 0: 1.0 : 15;
plot(x,f);
hold on;
plot(x,c)
and I tried to follow the example given in https://se.mathworks.com/matlabcentral/answers/23591-examples-of-multiple-plots-on-one-graph ( more specifically the accepted answer given by Chandra Kurniawan) , where a problem similar to what I am facing now was asked and answered.
Any help/thoughts/advice is extremely welcome! Thank you in advance

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 25 日
You can use yyaxis to plot 2 axis
x = 0:0.1:10;
yyaxis left
plot(x, x);
yyaxis right
plot(x, sin(x))
  6 件のコメント
Christian Nørgaard
Christian Nørgaard 2018 年 5 月 25 日
IT WORKED!!! THANKS !!!! 6 hrs of lovely troubleshooting is finally done!!!!!!!! Thanks a lot!
Ameer Hamza
Ameer Hamza 2018 年 5 月 25 日
You are welcome.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by