Sort a list of files

1 vue (au cours des 30 derniers jours)
Kevin Gnebner
Kevin Gnebner le 21 Juin 2019
Commenté : Kevin Gnebner le 4 Juil 2019
Hey guys,
i have a problem to sort my files which i load with "dir".
i want to sort my list depending on three numbers.
my unsorted list looks like:
'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -10,00°'
'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -15,00°'
'dantec7100_Ma=02_wait_1000_ Yaw -10,00° Pitch -10,00°'
'dantec7100_Ma=02_wait_1000_ Yaw -10,00° Pitch -15,00°'
'dantec7100_Ma=01_wait_1000_ Yaw 10,00° Pitch 10,00°'
'dantec7100_Ma=01_wait_1000_ Yaw 10,00° Pitch 15,00°'
'dantec7100_Ma=02_wait_1000_ Yaw 10,00° Pitch 10,00°'
'dantec7100_Ma=02_wait_1000_ Yaw 10,00° Pitch 15,00°'
....
Ma goes from 01 to 07
Yaw goes from -20 to 20
Pitch goes from -20 to 20
I want the following sequence for all "Ma" starting from 01 to 07:
I want to start with "Ma=01". Then the lowest Yaw-Angle (-20) has to follow and to be fixed, and the pitch angles have to follow from the lowest to the highest (-20 to 20). Than increase the yaw angle to -5 and run again all pitch angle from -20 to 20, and so on for all yaw-angles. When this is ready, i want to increase "Ma" to 02 and do the same again.
i hope my problem is clear.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 21 Juin 2019
Modifié(e) : Andrei Bobrov le 21 Juin 2019
data = { 'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -10,00°'
'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -15,00°'
'dantec7100_Ma=02_wait_1000_ Yaw -10,00° Pitch -10,00°'
'dantec7100_Ma=02_wait_1000_ Yaw -10,00° Pitch -15,00°'
'dantec7100_Ma=01_wait_1000_ Yaw 10,00° Pitch 10,00°'
'dantec7100_Ma=01_wait_1000_ Yaw 10,00° Pitch 15,00°'
'dantec7100_Ma=02_wait_1000_ Yaw 10,00° Pitch 10,00°'
'dantec7100_Ma=02_wait_1000_ Yaw 10,00° Pitch 15,00°'};
a = regexp(data,'(\-)?\d+(,\d+)?','match');
b = regexprep(cat(1,a{:}),',','.');
[~,ii] = sortrows(str2double(b(:,[2,4,5])));
out = data(ii);
  8 commentaires
Andrei Bobrov
Andrei Bobrov le 25 Juin 2019
Modifié(e) : Andrei Bobrov le 25 Juin 2019
a = regexp(data,'.*Ma=0[1-7].*Yaw\s+0,00.*Pitch\s+0,00°$','match','once');
out = a(~cellfun(@isempty,a));
or
a = regexp(data,'(\-)?\d+(,\d+)?','match');
b = regexprep(cat(1,a{:}),',','.');
M = str2double(b(:,[2,4,5]));
out = data(ismember(M(:,1),1:7) & M(:,2) == 0 & M(:,3) == 0);
Kevin Gnebner
Kevin Gnebner le 4 Juil 2019
Hey Andrei,
is it possible that i only get the indices, where the filenames with "0,00" are? as you did it in my first question.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by