Info
This question is closed. Reopen it to edit or answer.
help with using matrix index from previous iteration.
1 view (last 30 days)
Show older comments
hello guys, I hope you have a nice weekend. please, if anyone can help me with this problem related to the matrix index. Bellow is a part of my code.
d{11}=Q_{1:1}*(t(1))^3;
D{11}=(2/3)*d{11};
for ii=2:j
k=ii;ss=ii-1;
d{ii}=d{ss}+Q_{ii}*(((z(k))^3)-((z(k-1))^3));
D{ii}=(2/3)*d{ii};
end
i am trying to use the previous matrix d{ss} to calculate the new one d{ii}. i need all ds to use them in another iteration. the problem is i have this error.
error using +
Matrix dimensions must agree.
Error in Untitled (line 46)
d{ii}=d{ss}+Q_{ii}*(((z(k))^3)-((z(k-1))^3));
also i tried to use d{ii-1} and d{i-1i-1} but i always have the error message. please if there anyway how to insert the previous matrix in my iteration.
2 Comments
Jonathan Epperl
on 14 Oct 2012
How about you look at the matrices in question, for instance using a break point? In particular, what is the dimension of d{10}? My assumption is it is an empty array, and that will get you that error.
[]+magic(2)
%Error using +
%Matrix dimensions must agree.
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!