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!