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!