I dont know how to plot more than one regressions in one plot, like the picture i did in excel. I tried basic fitting tool but could not success, and i have look at multiple regression but could not understand becaus of no example. Thank for any help

1 回表示 (過去 30 日間)

採用された回答

Star Strider
Star Strider 2016 年 5 月 2 日
Something like this should work:
x = 1:10;
y1 = rand(1, 10);
y2 = rand(1, 10);
DM = [x', ones(length(x),1)]; % Design Matrix
B1 = DM \ y1'; % Estimate Parameters Of ‘y1’ Fit
B2 = DM \ y2'; % Estimate Parameters Of ‘y2’ Fit
y1_fit = DM*B1; % Calculate Fit For ‘y1’
y2_fit = DM*B2; % Calculate Fit For ‘y2’
figure(1)
plot(x, y1, '.b', x, y2, '.r') % Plot Data
hold on
plot(x, y1_fit, '--b', x, y2_fit, '--r') % Plot Fitted Regression Lines
hold off
grid
  2 件のコメント
Manh Nguyen
Manh Nguyen 2016 年 5 月 2 日
thank a lot, it was so headeach
Star Strider
Star Strider 2016 年 5 月 2 日
My pleasure.
If my Answer solved your problem, please Accept it.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 5 月 2 日
If you want a polyfit() example, see attached. Like Star showed, you just do the fit first for the first set of data, and plot that fit, then call hold on, and do it again for the second set of data.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by