Subtraction between a matrix and a column vector
11 views (last 30 days)
Show older comments
Akshay Vivek Panchwagh
on 5 Apr 2022
Commented: Akshay Vivek Panchwagh
on 12 Apr 2022
So I have a matrix of the size 23x15 and a column vector of size 23x1. I need to subtract element 1 of the colum vector from the 1st row of the matrix, element 2 of the column vector from 2nd row of the matrix, and so on. Any suggestions about how I can do it?
0 Comments
Accepted Answer
Riccardo Scorretti
on 5 Apr 2022
Hi. If the matrix and the vector have compatible size (= like you mentioned), it is enough to use the minus operator:
A = rand(23,15);
x = rand(23,1);
A-x
More Answers (1)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!