Dimension error in matrix manipulation
이전 댓글 표시
Hi, trying to figure out why this doesn't work and how to make it work:-
looktime2= [1 16; 2 55; 2 61; 2 66; 2 68; 5 20; 6 60; 8 47; 8 83; 8 105; 9 72; 10 44; 10 57]
t2 = [true;diff(looktime2(:,1))~=0]; t2 = [t2,looktime2(:,2)];
t2 = [1 16; 1 55; 0 61; 0 66; 0 68; 1 20; 1 60; 1 47; 0 83; 0 105; 1 72; 1 44; 0 57]
Rmatrix is a 10 by 121 matrix
for i = 1:size(t2,1)
for j = 1
if t2(i,j)==1
sd(i,j) = Rmatrix(looktime2(i,j),1:t2(i,j+1));
end
if t2(i,j)==0
sd(i,j) = Rmatrix(looktime2(i,j),t2(i-1,j+1):t2(i,j+1));
end
end
end
When I press enter I get an Subscripted assignment dimension mismatch error , but I'm not sure how to get it to work.
Any help will be much appreciated. Thanks
댓글 수: 2
Andrei Bobrov
2011년 8월 31일
that want to get?
Andrei Bobrov
2011년 8월 31일
error in the code
element double array assign vector
채택된 답변
추가 답변 (1개)
zohar
2011년 8월 31일
Hi Amandeep,
This is the problem
sd(i,j) = Rmatrix(looktime2(i,j),1:t2(i,j+1));
Subscripted assignment dimension mismatch.
Rmatrix(looktime2(i,j),1:t2(i,j+1)) is vector , and sd(i,j) is 1x1 you can not do that.
Have fun
카테고리
도움말 센터 및 File Exchange에서 Financial Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!