Have an array of 16 values, want to output them in order value by value, with the same string of text before each value
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Et.B200
el 10 de Nov. de 2020
Respondida: Stephen23
el 11 de Nov. de 2020
say amount = [a, b, c, d, e, f,] where a,b,c etc are numbers in an array.
Want to then output a list like this as an output with the same text string beforehand repeating but with the different values in this instance as there are 6 values to output:
For example i want the output to be:
The amount is: a
The amount is: b
The amount is: c
etc....
Want it to keep outputting until all values of amount are displayed like this
0 comentarios
Respuesta aceptada
Stephen23
el 11 de Nov. de 2020
The simple and efficient MATLAB approach is to use fprintf:
amount = [0,2,3,5,13,7];
fprintf('The amount is %d\n',amount);
0 comentarios
Más respuestas (1)
Sudhakar Shinde
el 11 de Nov. de 2020
Use for loop:
amount = [a, b, c, d, e, f];
for i=1:length(amount)
disp(['The amount is: ',amount(i)]);
end
0 comentarios
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!