Borrar filtros
Borrar filtros

Problem with string assembly

1 visualización (últimos 30 días)
judy abbott
judy abbott el 14 de Ag. de 2016
Comentada: judy abbott el 15 de Ag. de 2016
Hy all for my code,
V_AA = [100; 200]
L_AA = length(V_AA)
S_AA = num2str(V_AA)
for i=1:L_AA
F_AA{i} = ['N°: ' S_AA(i)];
end
i'm unable to get :
F_AA{1} = N°: 100
F_AA{2} = N°: 200
Thanks

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Ag. de 2016
Editada: Azzi Abdelmalek el 14 de Ag. de 2016
V_AA = [100; 200]
L_AA = length(V_AA)
for i=1:L_AA
F_AA{i} = sprintf('N°: %d', V_AA(i))
end
%or without for loop
F_AA=regexp(sprintf('N°: %d ', V_AA'),'N°: \d+','match')
  1 comentario
judy abbott
judy abbott el 15 de Ag. de 2016
Please for print how I do ?
i = 1
N°: 100
i = 2
N°: 200
Thank

Iniciar sesión para comentar.

Más respuestas (1)

Geoff Hayes
Geoff Hayes el 14 de Ag. de 2016
Judy - since S_AA is an array of characters, then
S_AA(i)
returns the first character only in the ith row. To return all characters, you would need to do
for i=1:L_AA
F_AA{i} = ['N°: ' S_AA(i,:)];
end
  1 comentario
judy abbott
judy abbott el 14 de Ag. de 2016
Thank you for the explication

Iniciar sesión para comentar.

Categorías

Más información sobre Engines & Motors 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