defining matrix for a loop

1 visualizzazione (ultimi 30 giorni)
Hashvi Sai
Hashvi Sai il 29 Lug 2021
Commentato: Hashvi Sai il 29 Lug 2021
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.

Risposta accettata

KSSV
KSSV il 29 Lug 2021
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.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by