What does the syntax matrix(vector) mean?
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm reviewing some code written by someone else, and it includes a line of the format:
a = m(v)
where m is a matrix and v is a vector. It's unclear to me exactly what operation this is performing. At first, I thought it was matrix multiplication, but the matrix does not have the proper dimensions to operate on the vector. The matrix is 1006x321, and the vector is 143x1. The output of this operation, a, is also a 143x1 vector. Since it can't be proper matrix multiplication, I really don't know what operation is being performed here. What exactly does this syntax mean?
댓글 수: 0
채택된 답변
Voss
2024년 7월 17일
댓글 수: 2
Voss
2024년 7월 17일
편집: Voss
2024년 7월 17일
You're welcome!
Here's an example to illustrate indexing a matrix with a vector:
m = reshape(100+(1:27),[],3)
v = 1:2:15 % a vector containing the odd numbers from 1 to 15
% a will contain the 1st, 3rd, 5th, ..., 15th elements of m.
% note that the counting goes down the first column of m first, then
% continues down the second column, and so on.
a = m(v)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!