subtracting columns of one matrix from the other and chaining the awnsers
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i have a matrix A=[1,2,3; 4,5,6 ; 7,8,9] and matrix B=[10,20,30,40; 10,20,30,40; 10,20,30,40]
i want to substract A(:,1)-B and chain it to A(:,2)-B and so on.
without using a loop!
any ideas??
0 comentarios
Respuestas (1)
Image Analyst
el 24 de Nov. de 2021
What is your definition of "chain"? Do you mean concatenate?
A(:, 1) is a column vector while B is a matrix. Were you planning on using automatic expansion?
A=[1,2,3; 4,5,6 ; 7,8,9]
B=[10,20,30,40; 10,20,30,40; 10,20,30,40]
% "i want to substract A(:,1)-B and chain it to A(:,2)-B and so"
m1 = A(:,1) - B
m2 = A(:, 2) - B
% Concatenate m1 to the right of m2
output = [m2, m1]
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!