defining matrix for a loop

1 Ansicht (letzte 30 Tage)
Hashvi Sai
Hashvi Sai am 29 Jul. 2021
Kommentiert: Hashvi Sai am 29 Jul. 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.

Akzeptierte Antwort

KSSV
KSSV am 29 Jul. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by