Borrar filtros
Borrar filtros

How To Separate each matrix column values with comma?

15 visualizaciones (últimos 30 días)
SAMEER ahamed
SAMEER ahamed el 3 de Mzo. de 2014
Respondida: Image Analyst el 3 de Mzo. de 2014
Hi,
I wanna to make matrix each column values separated with comma .please let me know ?
Example :
if true
% code
for int i =1:1
matrix =[co-ordinate_x;co-ordinate_y;co-ordinate_xy;co-ordinate_yy;co-ordinate_zx;co-ordinate_zy;co-ordinate_xz;co-ordinate_yz]; % here dynamic 1-by-8 matrix values
end
end
Note :I would like to form like matrix =[23,21,3,2,5,3,22,65]*

Respuesta aceptada

Image Analyst
Image Analyst el 3 de Mzo. de 2014
Isn't this just like you asked, and I answered, in http://www.mathworks.com/matlabcentral/answers/119642-how-to-get-vector-of-integer? Basically you just have to use sprintf() to insert commas or whatever characters you want. Why is this any different than that question?

Más respuestas (1)

Jos (10584)
Jos (10584) el 3 de Mzo. de 2014
using semi-colons in concatenation will put elements in columns, while using comma's will put them in rows. You can often omit the comma's
a = [1 ; 2 ; 4 ; 3] % a 4-by-1 vector
b = [a , 2*a] % 4-by-2 array
c = [1 , 2 ; 3 , 4]
d = [1 2 ; 3 4]
Note that ML does not show the semi-colons or comma's in displaying these matrices.
  3 comentarios
Jos (10584)
Jos (10584) el 3 de Mzo. de 2014
So, this is only for cosmetic purposes only:
matrix = [2 34 4 3]
fprintf('\nMatrix = ')
fprintf('%d,',matrix)
fprintf('%c\n',8) ; % print backspace, i.e, remove last comma (does NOT work when printing to files)
Jos (10584)
Jos (10584) el 3 de Mzo. de 2014
But I still prefer disp …
disp('Matrix = ')
disp(matrix)

Iniciar sesión para comentar.

Categorías

Más información sobre Logical 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