How do I replace the last value in the output string to 'and *value*.' instead of ', *value*,'?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Catalytic Kys
el 3 de Dic. de 2019
Editada: Catalytic Kys
el 3 de Dic. de 2019
How do I replace the last value in the output string to 'and *value*.' instead of ', *value*,'?
Any help is greatly appreciated!
Current output:
list: ... 53 (prime), 54, 55,
Desired output:
list: ... 53 (prime), 54 and 55.
Question mostly answered already below!
0 comentarios
Respuesta aceptada
Image Analyst
el 3 de Dic. de 2019
Try
for i = 1 : N
fprintf('%d', i);
if ismember(i, result)
fprintf(' (prime)');
end
if i < N
fprintf(', ');
else
fprintf('.\n');
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings 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!