フィルターのクリア

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

1 回表示 (過去 30 日間)
Abdallah Magour
Abdallah Magour 2024 年 1 月 23 日
コメント済み: Abdallah Magour 2024 年 1 月 23 日
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.

採用された回答

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by