How to solve the for loop with row and column?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Walter Roberson
el 26 de En. de 2018
"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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!