Subtraction between a matrix and a column vector
조회 수: 5 (최근 30일)
이전 댓글 표시
Akshay Vivek Panchwagh
2022년 4월 5일
댓글: Akshay Vivek Panchwagh
2022년 4월 12일
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
채택된 답변
Riccardo Scorretti
2022년 4월 5일
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
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!