Polyfit with weights for not allowed points

1 Ansicht (letzte 30 Tage)
alberto tonizzo
alberto tonizzo am 18 Dez. 2016
Bearbeitet: Matt J am 19 Dez. 2016
I have a multiple matrices that I'm trying to fit with multiple polyfit functions (see picture). I'd like to combine the matrices in one single matrix and then fit them with one polyfit function. The issue is that some columns of the matrices are empty (hence the curves in the picture don't cover the whole range), therefore I cannot combine all them together.
I hope this is clear. I would really appreciate some help. Thanks!

Antworten (2)

Matt J
Matt J am 18 Dez. 2016
Bearbeitet: Matt J am 18 Dez. 2016
There is nothing to be gained by combining the data, since polyfit will only process one pair of vectors (x,y) per call.
That aside, you can always use cell arrays to hold different sized data
  4 Kommentare
alberto tonizzo
alberto tonizzo am 18 Dez. 2016
Thanks but Jos assumed that the sets are row vectors, instead they are matrices with different number of columns. How do I deal with that? Specifically:
  • X1 is [330x24] - red curve in the plot
  • X2 is [330x20] - blue
  • X3 is [330x14] - cyan
  • X4 is [330x12] - magenta
  • X5 is [330x10] - green
Matt J
Matt J am 19 Dez. 2016
Bearbeitet: Matt J am 19 Dez. 2016
You can turn any matrix into a row vector as follows
rowvector=matrix(:).';
or
rowvector=reshape(matrix,1,[]);

Melden Sie sich an, um zu kommentieren.


Jos (10584)
Jos (10584) am 18 Dez. 2016
You can simply concatenate the data into a single vector
% xk, yk are your data sets. concatenate them into a single vector
x_combined = [x1 x2 x3] % assuming sets are row vectors
y_combined = [y1 y2 y3]
p = polyfit(x_combined, y_combined, ...)
  1 Kommentar
alberto tonizzo
alberto tonizzo am 18 Dez. 2016
Jos - Unfortunately the sets are matrices of max 24 rows (and 330 lines). I said "max" because some of the columns are empty for some matrices, specifically:
  • X1 is [330x24] - red curve in the plot
  • X2 is [330x20] - blue
  • X3 is [330x14] - cyan
  • X4 is [330x12] - magenta
  • X5 is [330x10] - green

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices 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