match the same files in a loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello folks,
I have two folders with different parameters. I would like that my loop match and compute the files that has the same parameters. Any simple ideas on how can I do that please.
Example of the content of my folders:
The first folder:
StokesParameters_Synthetic_Star_Gain_10000000000-Real_5-Int_a=1.5_incl=90.0_pa=90.0_e=0.6_wave=900
The second folder:
Linear_Separable_Model_Synthetic_Star_Gain_10000000000-Real_5-a_Int_a=1.5_incl=90.0_pa=90.0_e=0.6_wave=900
2 Kommentare
Yongjian Feng
am 6 Jul. 2021
It seems to me that you need to parse the file name string to extract parameters first. Then do the comparison.
Antworten (1)
dpb
am 6 Jul. 2021
f='StokesParameters_Synthetic_Star_Gain_10000000000-Real_5-Int_a=1.5_incl=90.0_pa=90.0_e=0.6_wave=900';
res=split(f,'_');
res=strcat(res(contains(res,"=")),';');
cellfun(@eval,res)
leaves in the workspace (in addition to anything else already there)
>> whos
a =
1.5000
incl =
90
pa =
90
e =
0.6000
wave =
900
>>
"Poofing" variables into the workspace isn't really an ideal thing to do; that was more just for grins to show could be done than in earnest "since you asked". :)
The problem here is that when you do another file/folder name string, it will overwrite those variables with the new copies of the same variables so you there's no way to actually compare the two.
What you really would need to do would be to set up an array and extract both sets into different arrays so can compare the two.
Or, you could do a string comparison of the entries in the res array from two cases by have two of those arrays--that would, presuming the naming patterns are consistent, let one find whether any of those strings were different.
1 Kommentar
Siehe auch
Kategorien
Mehr zu Variables 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!