필터 지우기
필터 지우기

Dividing a Matrix with a column vector

조회 수: 16 (최근 30일)
Lorenzo Pinna
Lorenzo Pinna 2021년 1월 28일
댓글: Lorenzo Pinna 2021년 1월 28일
Hello everyone.
I am having a problem doing a matrix by vector division. The matrices and vectors are here attached.
The operation would be q_i(10000 X 4)= p_i (10000X4)./P(1X4).
The result should be that each element of the coloumn of p_i have to be divided by the element of P of that column. Thus, giving a result different for each column (equal within the columns since the matrix p_i has this peculiarity). Instead, in my case, the outcome is a matrix 100000X4 whose elements are all equal. I am not able at all in managing this problem. If someone can help me to solve this I would be very grateful.
Thanks!
Lorenzo

채택된 답변

Jan
Jan 2021년 1월 28일
The p_i, you have provided, is not [10000 x 4] but [4 x 10000]. When I load the files and run:
q_i = p_i.' ./ P;
I get a [10000 x 4] matrix with different values as expected.
Therefore it is not clear, how you have created your q_i. The problem must be a a location, you did not mention yet.
  댓글 수: 2
the cyclist
the cyclist 2021년 1월 28일
@Jan was quicker to reply. I got exactly what he describes.
Lorenzo Pinna
Lorenzo Pinna 2021년 1월 28일
I am sorry to have not specified that this goes in a loop.
Therefore, I am in a loop
for i=1:N N=10000
for t=1:T T=4
and q_i is (TXN), p_i is (TXN) and P is (1XT).
The exact operation is q_i(t,i)=p_i(t,i)./P(t).
Doing this operation the outcome is the matrix q_i attached above.
Effectively, if I do as I described before, the result which I obtain is correct. I would like to obtain the result you get but inside of the loop. with the q_i's numbers equals within the column and different between.
Thanks and sorry for the incovenient

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by