matlab - save multiple matrices in dir after truncating -


i working code, based on previous user examples. trying read ascii files in directory specified , read first 80 rows of data each file (1020 total rows , 2 columns, originally). routine not give me errors it's unclear me how data stored in matlab, , how can manipulate each of new matrices of 80 rows i've created. can give each .asc file truncated new file name or matrix assignment? next need peakfinding algorithm on 80 rows in each file, need each of them stored separately. thanks!

folder = fullfile('users', ...'documents', 'matlab');   f = dir(fullfile(folder, '*.asc'));      matrices = struct();        ii = 1 : numel(f)            name = fullfile(folder, f(ii).name);           o = dlmread(name);          matrices.(f(ii).name) = o(1:80,:);       end 

this won't work.

the loop loops files in directory. each file read temporary matrix o, first 80 lines stored structure matrices. but: matrices structure referenced full file names of corresponding asc files i.e. blabla.asc

matlab structs referenced dots , consequently forbids dots in field names structs.

change code to:

f = dir(fullfile(folder, '*.asc')); matrices = struct(); ii = 1 : numel(f)     name = fullfile(folder, f(ii).name);     o = dlmread(name);     prf_sff = strsplit(f(ii).name, '.')     matrices.(prf_sff{1}) = o(1:80,:); end 

then can reference matrix containing first 80 lines of blabla.asc with:

matrices.blabla 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -