Borrar filtros
Borrar filtros

issues with fprintf

2 visualizaciones (últimos 30 días)
Abra dog
Abra dog el 1 de Nov. de 2011
I'm trying to list out something in fprintf how do i do it one at a time? Example: fprintf('blahhh blahh %s blahh bahh\n',K) K = text1 text2 I want it to say blahh blahh text1 blahh blahh and then in another row under it blahh blahh text 2 blahh blahh

Respuesta aceptada

Grzegorz Knor
Grzegorz Knor el 1 de Nov. de 2011
K = {'text1'; 'text2'};
arrayfun(@(idx)fprintf('blahhh blahh %s blahh bahh\n',K{idx}),1:numel(K))

Más respuestas (1)

Daniel Shub
Daniel Shub el 1 de Nov. de 2011
fprintf is vectorized ...
K = {'text1'; 'text2'};
fprintf('blahhh blahh %s blahh bahh\n',K{:})
gives the same results as the accepted answer.
  1 comentario
Grzegorz Knor
Grzegorz Knor el 1 de Nov. de 2011
Thanks for the hint. I did not know that it can be done with cell arrays.

Iniciar sesión para comentar.

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by