Azzera filtri
Azzera filtri

can I adjusting one vector according to another vector for plotting?

1 visualizzazione (ultimi 30 giorni)
Hi, I have this matrix for example like this:
Matrix M=
2 4 1 4 6
2 5 NaN 8 1
4 NaN 9 NaN NaN
9 6 NaN NaN 7
And vector T=
1
2
3
4
I am trying to plot vector T on the x-axis with every row column of matrix M on the y-axis. This works fine the plot aoutoatically ignore the points with NaN.
The problem is I would also like to use polyfit, to get a fitting equation. But Polyfit is does not skip NaN values, which gives only NaN as coefficients. Please note that I the matrix M is orignally a much larger matrix same as vector T is much larger. These are just examples for my point.
My question is is there a another way to get the equation of a fitted line fo every coumn vs vector T.
Example, the option in the graph tools> basic fitting works great, but this is manual. I need to output the fitting equations for large matriceis in a for loop and store them.

Risposta accettata

Matt J
Matt J il 23 Gen 2024
Given x,y for fitting,
I=~isnan(x)&~isnan(y);
p=polyfit(x(I), y(I),1)

Più risposte (0)

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by