フィルターのクリア

how to make group by extracting data?

2 ビュー (過去 30 日間)
hj lee
hj lee 2020 年 10 月 6 日
コメント済み: Star Strider 2020 年 10 月 7 日
Hello,
e = [-9:3:9];
CM =
0.41 0.39 0.37 ....
0.32 0.30 0.29 ...
0.24 0.22 0.20 ...
0.15 0.13 0.12 ....
0.06 0.05 0.03 ...
-0.01 -0.03 -0.05 ...
-0.10 -0.12 -0.13 ...
CM is 7*20 double,
and
ele1 = interp1(CM(:,1),e,0);
ele2 = interp1(CM(:,2),e,0);
....
ele20 = interp1(CM(:,3),e,0);
ele = [ele1 ele2 ..... ele20]
This method have to write each group, so I want to make it more simply
(I just want to result 'ele = [ele1 ele2 ... ele20]', I don't need to enumerate all components)
Thanks for reading.

採用された回答

Star Strider
Star Strider 2020 年 10 月 6 日
I am not certain what you want to do. One problem is that the elements of ‘CM’ appear to be outside the range of (-9,9). In any event, the first argument must be a vector. If you want to do the interpolation in the order of arguments you chose, a loop is the only option:
CM = sort(randi([-9 9], 7, 20)+rand(7,20),2)/10; % Create ‘CM’
e = [-9:3:9];
for k = 1:size(CM,2)
ele(k) = interp1(CM(:,k),e,0, 'linear','extrap');
end
.
  2 件のコメント
hj lee
hj lee 2020 年 10 月 7 日
Thank you very much!
Star Strider
Star Strider 2020 年 10 月 7 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by