フィルターのクリア

Build arrays under the for loop

6 ビュー (過去 30 日間)
Mohamed Zied
Mohamed Zied 2023 年 2 月 13 日
コメント済み: Mohamed Zied 2023 年 2 月 14 日
Hi;
for i=1:10
R"i"= nonzeros(D(i,:));
end
I want to create arrays under the for loop. The arrays wont have the same size. For each increment, the name of the array should be R + the increment number (R1, R2, R3 ....).
The desired result is 10 vectors R1 to R10.
Any hints to do it ?
Thank you in advance
  1 件のコメント
Stephen23
Stephen23 2023 年 2 月 13 日
Use indexing. Indexing is a MATLAB superpower. If you do not use indexing, then using MATLAB will be very ... difficult.

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

回答 (1 件)

KSSV
KSSV 2023 年 2 月 13 日
編集済み: KSSV 2023 年 2 月 13 日
R = cell(10,1) ;
for i=1:10
R{i}= nonzeros(D(i,:));
end
You can access by R{1},R{2},...R{10}. R is a cell array. You need not to name it as R1, R2...R10.
  1 件のコメント
Mohamed Zied
Mohamed Zied 2023 年 2 月 14 日
The aim is to use this arrays with distributionFitter. I build a cell array, but it couldn't be used with distributionFitter. That's why I am looking for another solution.

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

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by