Want to make linear fitting and plot both graph on the same curve
5 ビュー (過去 30 日間)
表示 古いコメント
I have x, y data
x=[0;0.100000000000000;0.200000000000000;0.300000000000000;0.400000000000000;0.500000000000000;0.600000000000000];
y=[4.67178152947921e-06;4.67353333624452e-06;4.70560728038426e-06;4.74873086195845e-06;4.77333265701103e-06;4.84630647442201e-06;4.87015810633671e-06];
I want to plot x vs y and want to have y-axis in log scale ( NOT log the y data)
this is how I make y -axis with log scale
plot(x,y)
set(gca,'YScale','log')
hold on
Note: x data starts from 0
Now I want to fit a line and show the slope of that curve fitting line + original curve
this is for fitting line.
p=polyfit(x,(y),1);
q=polyval(p,x);
plot(x,q).
It seems to be not right because the fit line isn't straight (it likes power fit or exponential) because it does not start at Initial point . Note log scale ( not log(data))
Please helps. Thanks
1 件のコメント
Daniel Shub
2013 年 3 月 20 日
編集済み: Daniel Shub
2013 年 3 月 20 日
This is a duplicate of http://www.mathworks.com/matlabcentral/answers/67684-want-to-fit-linear-curve-on-my-data. Please do not post duplicates, it tends upsets the people who are likely to provide answers.
採用された回答
bym
2013 年 3 月 19 日
you are going to have to transform your data:
x=[0;0.100000000000000;0.200000000000000;0.300000000000000;0.400000000000000;0.500000000000000;0.600000000000000];
y=[4.67178152947921e-06;4.67353333624452e-06;4.70560728038426e-06;4.74873086195845e-06;4.77333265701103e-06;4.84630647442201e-06;4.87015810633671e-06];
semilogy(x,y,'bo')
c = polyfit(x,log(y),1)
p = polyval(c,x)
hold
semilogy(x,exp(p),'g')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Find more on Get Started with Curve Fitting Toolbox 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!