Rename and processing data

1 visualizzazione (ultimi 30 giorni)
zakaria azdad
zakaria azdad il 21 Lug 2019
Commentato: dpb il 21 Lug 2019
Dear Matlaber,
I have a bunch of output files in the folowing format X.0.ii.out where .ii goes from 00 to 40 with an increament of 01.
I would like to upload these files on matlab and conduct a search task. I am looking for a matrix of 3x3 after a line starting with 'total stress'. This lines appear at multiple occasion in the output file and I just need the last matrix. The code is below
fmt1='total stress%n';
fmt2=['(' repmat('%f',1,3) ')'];
flds={'X','Y','Z'};
fid=fopen(X*.out,'r');
dat=struct([]);
i=0;
while ~feof(fid)
i=i+1;
dat(i).m=cell2mat(textscan(fid,fmt1,1));
for j=1:length(flds)
dat(i).(flds{j})=cell2mat(textscan(fid,fmt2,3,'collectoutput',1)).';
end
end
fid=fclose(fid);
this one does not work as X*.out is not a calid syntax in matlab an it gives all the 3x3 matrix in the file.
any idea how to solve this?
  3 Commenti
zakaria azdad
zakaria azdad il 21 Lug 2019
After correcting
d=dir('X*.out')
this gives an error for
fopen(d(i).name,'r')
Subscript indices must either be real positive integers or logicals.
dpb
dpb il 21 Lug 2019
'Cuz I automatically write 'i' for indices and you'd already used it so I wrote 'f' for the for loop index but see beginning of sentence...fix the subscript to match the loop variable.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Entering Commands 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