Borrar filtros
Borrar filtros

how do i fprintf 2 variables like this

1 visualización (últimos 30 días)
Austin
Austin el 1 de Oct. de 2013
Comentada: Austin el 2 de Oct. de 2013
kindly advise,thanks alot!

Respuesta aceptada

Image Analyst
Image Analyst el 1 de Oct. de 2013
for row = 1 : 6
fprintf('The sum of row %d = %f\n', row, sum(yourMatrix(row, :)));
end

Más respuestas (1)

dpb
dpb el 1 de Oct. de 2013
Editada: dpb el 2 de Oct. de 2013
One way amongst many...
>> sfx={'st';'nd';'rd';'th'};
>> isf=[1:3 repmat(4,1,3)];
>> for ix=1:6
fprintf('The sum of %d%s row is %.3f\n',i, sfx{isf(ix)}, sum(x(ix,:)))
end
The sum of 1st row is 0.564
The sum of 2nd row is 1.843
The sum of 3rd row is 0.702
The sum of 4th row is 1.888
The sum of 5th row is 1.551
The sum of 6th row is 0.627
>>
  1 comentario
Austin
Austin el 2 de Oct. de 2013
Thanks Alot your solutions works too!

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements 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