Dimension error in matrix manipulation
Mostrar comentarios más antiguos
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 comentarios
Andrei Bobrov
el 31 de Ag. de 2011
that want to get?
Andrei Bobrov
el 31 de Ag. de 2011
error in the code
element double array assign vector
Respuesta aceptada
Más respuestas (1)
zohar
el 31 de Ag. de 2011
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
Categorías
Más información sobre Financial Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!