how to display coefficient and offset on graph?

I'd like to display some values to plot. What should I do ?
A=xlsread('A.xlsx');
t=A(:,1);
i=A(:,2)/10^(2);
ft = fittype('a*exp(-x/b)+c');
F=fit(t,i,ft)
b = 1/F.b;
offset = F.c;
plot(t,i);
hold on;
plot(F)
hold off
It's an example plot, I'd like to make a plot through codes like this figure.
Capture.PNG

 採用された回答

Vishnu Vardhan
Vishnu Vardhan 2019 年 6 月 17 日

0 投票

Hi Jaehwi
You can use text function available in MATLAB by specifying the location of text wherever you want.
txt = {'b=0.007','Offset='};
text(220,10.5,txt)
This documentation may help you further

6 件のコメント

Jaehwi Bong
Jaehwi Bong 2019 年 6 月 17 日
Thank you for your answer.
I'd like to display those values on the plot from the result of fitting.
Vishnu Vardhan
Vishnu Vardhan 2019 年 6 月 17 日
you can replace with
txt = {'b=' num2str(b) 'Offset='}
Jaehwi Bong
Jaehwi Bong 2019 年 6 月 17 日
I can't still anything on the plot.
plot(t,i);
hold on
plot(F)
hold off
xlabel('Frame number')
ylabel('Intensity')
txt = {'b=' num2str(b) 'Offset=' num2str(offset)};
text(700,10.5,txt,'FontSize',14))
It plots without text...
Vishnu Vardhan
Vishnu Vardhan 2019 年 6 月 17 日
It looks like your x and y co-ordinates are out of the chart for the text function.
It should be something like this
text(220,10.5*10^5,txt,'FontSize',14)
Jaehwi Bong
Jaehwi Bong 2019 年 6 月 17 日
Vishnu Vardhan
Vishnu Vardhan 2019 年 6 月 17 日
fitoptions should work fine , Once verify whether limits are correct.
Once go through this link , might help you in someway.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by