Generate fitting curve from timetable plot

5 ビュー (過去 30 日間)
Roger Gomila
Roger Gomila 2020 年 3 月 30 日
コメント済み: Hiro Yoshino 2020 年 3 月 30 日
I have this table with percentatge values over time. When I do a scatter plot i get the following:
I would like tot fit a line over these points so that it show like this:
I know probably is easy to do, but I amb quite new to matlab programming and I've been wasting a couple of hours trying to do it but I am just getting different errors for each new method I try. I just could plot a linear regression, which I didn't want because it does not fit the plot shape.
Thank you in advance
  1 件のコメント
David Wilson
David Wilson 2020 年 3 月 30 日
So when you say above " would like tot (sic) fit a line over these points", you really mean a smooth curve that runs through the data cloud?
Do you have the curvefitting toolbox or the optimisation toolbox?
If not, then you have made more work for yourself, but you can always follow:

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

採用された回答

Hiro Yoshino
Hiro Yoshino 2020 年 3 月 30 日
Curve fitting app would suit you.
You can play around the various methods built in MATLAB.
  2 件のコメント
Roger Gomila
Roger Gomila 2020 年 3 月 30 日
Thanks, it worked now! But I have another trouble. I am trying to plot two different lines in the same figure, but I can't change the colors of the lines. Do you know how to do it?
% Plot fit with data.
figure( 'Name', 'B3 and B4' );
hold on
plot( fitresult{1}, xData_B3, yData_B3,'Color',[0.87451 0.11765 0.15]); % Color is not working
plot( fitresult{2}, xData_B4, yData_B4,'Color',[0.98431 0.63921 0.102]);
Thanks
Hiro Yoshino
Hiro Yoshino 2020 年 3 月 30 日
figure( 'Name', 'B3 and B4' );
hold on;
plot(fitresult{1}, 'b');
plot(xData_B3, yData_B3, 'bo');
plot(fitresult{2}, 'r');
plot(xData_B4, yData_B4, 'ro');
hold off;
Try this!?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by