How to solve the for loop with row and column?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello. I have an equation which is in a for loop. The equation is like that,
for i=1:length(LIN.fK)
linecurrent(i)=(conj(uK(LIN.fK(i,1)))-conj(uK(LIN.tK(i,1))))*(conj(Grid.YKK(LIN.fK(i),LIN.tK(i))));
end
Where length(LIN.fK)=131
uK= voltage (69x96 matrix)
LIN.fK= from bus (131x1 matrix)
LIN.tK= to bus (131x1 matrix)
Grid.YKK= bus admittance matrix (69x69 matrix)
The thing is if I do this for loop it shows answers like 131 answers. However, my voltage(uK) is basically (69x96) matrix. so I want the result in such a way that it will show (131x96 matrix). Here 131 is number of lines, 96 means time steps. Could anyone help me regarding this?
댓글 수: 0
답변 (2개)
Walter Roberson
2018년 1월 26일
"uK= voltage (69x96 matrix)"
But you have
uK(LIN.fK(i,1))
which indexes the 69x96 matrix with a single subscript. Is LIN.fK linear indices into the entire uK matrix?
I suspect you might have wanted
uK(LIN.fK(i,1), :)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!