defining matrix for a loop

2 ビュー (過去 30 日間)
Hashvi Sai
Hashvi Sai 2021 年 7 月 29 日
コメント済み: Hashvi Sai 2021 年 7 月 29 日
hi
i need to define a matrix to write an output.
the code i used is
txtFiles = dir('*.txt') ;
N = length(txtFiles) ;
PSDsheet = zeros( N,16);
..........................
........................
.........................
PSDsheet (n,:) = AllPSD
while im running this 'Unable to perform assignment because the size of the left side is 1-by-16 and the size of the right side is 3-by-16'.
Please help me what i need to modify.

採用された回答

KSSV
KSSV 2021 年 7 月 29 日
txtFiles = dir('*.txt') ;
N = length(txtFiles) ;
PSDsheet = cell( N,1);
..........................
........................
.........................
PSDsheet{n} = AllPSD
OR
txtFiles = dir('*.txt') ;
N = length(txtFiles) ;
PSDsheet = zeros( N,3,16);
..........................
........................
.........................
PSDsheet(n,:,:) = AllPSD
Bottom line either save them into cell if you don't know dimensions or save them into 3D matrix if you know the dimensions.
You are getting error becuase, you are trying to save more number of elements than initalized for.
  1 件のコメント
Hashvi Sai
Hashvi Sai 2021 年 7 月 29 日
thanks a lot

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by