Filter löschen
Filter löschen

matlab polyfit multiple sets of y data

6 Ansichten (letzte 30 Tage)
peter huang
peter huang am 16 Mär. 2023
Bearbeitet: Dyuman Joshi am 16 Mär. 2023
If I have multiple sets of data (y) under the same x condition, how can I polyfit a fitting line representing these data
If I have multiple y data, how can I use polyfit to get a fitting line about the two y data or what method should I use to get a line representing the two data
x = [1; 2; 3; 4; 5];
%%
y1 = [10; 20; 30; 40; 50];
y2 = [15; 25; 35; 45; 55];
  1 Kommentar
Dyuman Joshi
Dyuman Joshi am 16 Mär. 2023
Bearbeitet: Dyuman Joshi am 16 Mär. 2023
How do you get y1, y2, ...? Are they output from some code or are you manual inputting them?
Dynamically naming variables is not a good idea - Why Variables Should Not Be Named Dynamically

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 16 Mär. 2023
Run a loop for each set.....
Let y be your mxn data and x be your 1xn data.
p = cell(m,1) ;
for i = 1:m
p{i} = polyfut(x,y(i,:),2) ;
end
  1 Kommentar
peter huang
peter huang am 16 Mär. 2023
If I have multiple y data, how can I use polyfit to get a fitting line about the two y data or what method should I use to get a line representing the two data

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by