Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Abdallah Magour
Abdallah Magour le 23 Jan 2024
Commenté : Abdallah Magour le 23 Jan 2024
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.

Réponse acceptée

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

Plus de réponses (0)

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by