How do I output the same single parameter for a set of different files?
Afficher commentaires plus anciens
I have a code that I want to use to extract a particular parameters from all files in my directory with a .mat ending. I have set a loop to calculate the parameter R for each of the input files but I have made a mistake somewhere which means it records the value from the final loop for every element in the array. I'm not sure where I'm going wrong as the parameter I'm calculating is part of the loop. I know this is a simple question but I can't find an answer to it anywhere so help would be appreciated.
files = dir('*.mat');
Rarray = zeros(1,19);
for file = files'
matfile = load(file.name);
A4 = cf*A+B+cf*C;
B4 = cf*C+D+cf*E;
C4 = cf*E+F+cf*G;
D4 = cf*G+H+cf*A;
V = 2*complex(A4-C4,B4-D4)./(A4+B4+C4+D4);
for m=1:19
R = sum(abs(V))/length(V);
Rarray(m)=R
end
end
Réponse acceptée
Plus de réponses (1)
madhan ravi
le 31 Oct 2018
0 votes
5 commentaires
JJH
le 31 Oct 2018
madhan ravi
le 31 Oct 2018
for file = 1:numel(files')
Because didn’t even run as you think that’s why I told you to read the link but you didn’t!
JJH
le 31 Oct 2018
madhan ravi
le 31 Oct 2018
files = dir('*.mat');
Rarray = zeros(1,19);
for n = 1:numel(files')
matfile1(n) = load(file.name); %matfile is an inbuilt function so I renamed it
A4 = cf*A+B+cf*C;
B4 = cf*C+D+cf*E;
C4 = cf*E+F+cf*G;
D4 = cf*G+H+cf*A;
V = 2*complex(A4-C4,B4-D4)./(A4+B4+C4+D4);
for m=1:19
R = sum(abs(V))/length(V);
Rarray(m)=R
end
end
JJH
le 31 Oct 2018
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!