For Loop with index inside of a Matrix
Show older comments
Hi all, I am trying to compute this 6x6 matrix associate with index k. My code looks like this:
T=zeros(6,6);
for k=1:1:5;
S(k)=exp(2.*k.*pi.*1i./(n+1))
%T(k,:)=zeros(k,:);
T(k,:)=[-G1 G1+G2+G3+S(k)*C1 -G3-S(k)*C2 0 0 0;
0 -G3 0 0 0 0;
0 0 -G4 G4+G5+G6+S(k)*C3 -G5 0;
0 0 0 -G6 -S(k)*C4 0;
0 0 0 0 -G7 G7+S(k)*C5;
1 0 0 0 0 0];
end
The error I got is "Subscripted assignment dimension mismatch." at "T(k,:)=[-G1 G1+G2+G3+S(k)*C1 -G3-S(k)*C2 0 0 0;"
How to fix this? Where does it go wrong? Thank you for your inputs.
Frank
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!