フィルターのクリア

Problems with printing superscripts in a textbox in a graph

3 ビュー (過去 30 日間)
Fyodor Tatarinov
Fyodor Tatarinov 2021 年 4 月 12 日
コメント済み: Fyodor Tatarinov 2021 年 4 月 14 日
Dear colleagues,
I need to write regression results on graphs with several subplots. Texts are prepared in the same loop:
[c3,r2] = fit(data.P_mm_yr(aaa),data.ET_mm_yr(aaa),f);
subplot(Nrows,Ncols,i);
plot(c3,data.P_mm_yr(aaa),data.ET_mm_yr(aaa));
xlim([0 4000]); ylim([0 4000]);
paramstxt = cell(3,1);
paramstxt{1}=num2str(c3.a0,3);
paramstxt{2}=num2str(c3.a1,3);
paramstxt{3}=num2str(c3.c,3);
txtE = {strcat('y = ',paramstxt{1},'*x/(1+',paramstxt{2},'*x^{\',paramstxt{3},'}',')')...
;strcat('R^2 = ' ,num2str(r2.adjrsquare,2))};
text(800,3000,txtE);
legend('off');
However, in some cases text output is OK, e.g., this one:
'y =2.05e+04*x/(1+200*x^{\0.728})'
'R^2 =-0.11'
And in other cases I got the error message:
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax:
y =0.925*x/(1+2.82e-07*x^{\2.15})
R^2 =0.33
What is a problem?
Another question: on the graph with regression results (points and regression line) I need also to add a strate line 1:1. How can I do it?

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 4 月 12 日
編集済み: Cris LaPierre 2021 年 4 月 12 日
Remove the backslash in your exponent.
c3.a0 = 0.925;
c3.a1 = 2.82e-7;
c3.c = 2.15;
r2.adjrsquare = -0.11;
paramstxt = cell(3,1);
paramstxt{1}=num2str(c3.a0,3);
paramstxt{2}=num2str(c3.a1,3);
paramstxt{3}=num2str(c3.c,3);
txtE = {strcat('y = ',paramstxt{1},'*x/(1+',paramstxt{2},'*x^{',paramstxt{3},'}',')')...
;strcat('R^2 = ' ,num2str(r2.adjrsquare,2))};
text(800,3000,txtE);
xlim([0 4000]); ylim([0 4000]);
Also, for straight lines, look into xline and yline.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by