combine two matrices to get another matrix of same size

2 visualizaciones (últimos 30 días)
tanveer haq
tanveer haq el 20 de Nov. de 2018
Comentada: Ani Asoyan el 23 de En. de 2020
I have two matrices of same order say 'a' and 'b':
a=[1,2;3,4];
b=[5,6;7,8];
How to combine these matrices in order to get a 3rd matrix of the form:
c=[15,26;37,48]
i.e. each cell of first matrix combine with corresponding cell of another matrix.

Respuesta aceptada

madhan ravi
madhan ravi el 20 de Nov. de 2018
Editada: madhan ravi el 20 de Nov. de 2018
>> a=string([1,2;3,4]);
b=string([5,6;7,8]);
c=str2double(strcat(a,b))
c =
15 26
37 48
>>
  10 comentarios
Walter Roberson
Walter Roberson el 23 de En. de 2020
That is not valid in MATLAB unless you switch to string. It is not possible to have a numeric entry that has a negative sign in the middle of it and have the negative preserved.
Ani Asoyan
Ani Asoyan el 23 de En. de 2020
ok I got it. Thank you very much

Iniciar sesión para comentar.

Más respuestas (1)

Bruno Luong
Bruno Luong el 20 de Nov. de 2018
>> a=[1,2;3,4];
>> b=[5,6;7,8];
>> a*10+b
ans =
15 26
37 48
  3 comentarios
madhan ravi
madhan ravi el 20 de Nov. de 2018
Editada: madhan ravi el 20 de Nov. de 2018
+1 , this is the efficient method @Tanveer

Iniciar sesión para comentar.

Categorías

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