sprintf literal output as next pending command

1 vue (au cours des 30 derniers jours)
Octavian
Octavian le 25 Déc 2014
Commenté : Jan le 29 Déc 2014
Dear All,
I have a cell array DD with cells containing strings formed from letters, eg 'SFG' (some consecutive cells have identical contents, say 'SFG', but not all; essentially, DD is a list of name roots). I try to use the following code:
for i=1:2:(length(DD)-1)
groups((i+1)/2,:) = {sprintf('[A(find(strcmp({A.name},%4s )==1)),A(find(strcmp({A.name},%4s )==1))],/n',DD{i}, DD{i+1})}
end
to generate a cell array, each row of which would look like
[A(find(strcmp({A.name}, SFG )==1)),A(find(strcmp({A.name}, SFG )==1))],
where two consecutive name roots are to be grouped. The reason is that the roots are followed without spaces by numerical characters (eg "SFG3") which I have to manually enter after each root in each row above, then execute the grouping (the 'groups'). I need to do this as there are many name pair configurations that I need to use, some defying automation, and ever changing). What I need to do when I execute the for loop command, is to have the 'groups' ready at the command line for filling in the numbers, then execute, and not as answer which then I have to copy paste in the command line before filling in the numbers.So I would need the output from the for loop to figure as the next command to be executed, but only after I introduce all the no.
Please advise,
Octavian
  2 commentaires
per isakson
per isakson le 25 Déc 2014
Modifié(e) : per isakson le 25 Déc 2014
Why not
  • output the lines to an m-file
  • open the m-file in the editor
  • make the changes and save
  • run the m-file
  • keep the m-file as documentation
  • comment out lines and rerun the m-file as needed
Jan
Jan le 29 Déc 2014
Remark:
A(find(strcmp({A.name}, 'SFG')==1))
can be simplified to:
A(strcmp({A.name}, 'SFG'))

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur System Commands dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by