- 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
sprintf literal output as next pending command
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
per isakson
el 25 de Dic. de 2014
Editada: per isakson
el 25 de Dic. de 2014
Why not
Jan
el 29 de Dic. de 2014
Remark:
A(find(strcmp({A.name}, 'SFG')==1))
can be simplified to:
A(strcmp({A.name}, 'SFG'))
Respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!