"Subscriped assignment dimension missmatch" Error
조회 수: 1 (최근 30일)
이전 댓글 표시
So I'm trying to calculate the value of an unknown that would generate the maximum value in a matrix, but I've ran into a problem. I get the error "Subscripted assignment dimension mismatch". So to clarify, I'm looking for the p that, after the operation below is performed, Generates the highest number. I then need to find that p.
pvalues = [0:0.01:1];
v = [1;0];
for i=1:length(pvalues)
p=pvalues(i)
A = [2-p 0.25*p;p (1.25-(0.25*p))];
answer(i) = (A^25)*v;
end
max(answer)
I thought i could work around it, but it seems that it hasn't worked.
댓글 수: 0
답변 (1개)
BhaTTa
2024년 10월 21일
Hey @Lukas Lehrman, hey there is a minor mistake in your code as 'A' is 2x2 matrix and 'v' is 2x1 matrix and the resultant matrix obtained after their multiplication is 2x1 matrix, thereby you should assign the value to answer by doing answer(i,:).
pvalues = [0:0.01:1];
v = [1;0];
for i=1:length(pvalues)
p=pvalues(i)
A = [2-p 0.25*p;p (1.25-(0.25*p))];
answer(i,:) = (A^25)*v;
end
max(answer)
hope it resolved your issue.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!