Info

此问题已关闭。 请重新打开它进行编辑或回答。

help with using matrix index from previous iteration.

1 次查看(过去 30 天)
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 个评论
Jonathan Epperl
Jonathan Epperl 2012-10-14
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.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by