defining matrix for a loop

3 vues (au cours des 30 derniers jours)
Hashvi Sai
Hashvi Sai le 29 Juil 2021
Commenté : Hashvi Sai le 29 Juil 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.

Réponse acceptée

KSSV
KSSV le 29 Juil 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.
  1 commentaire
Hashvi Sai
Hashvi Sai le 29 Juil 2021
thanks a lot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by