how can i write a for loop for g=[2 5 6 8 9]

1 次查看(过去 30 天)
i have g=[2 5 6 8 9]
i want to write a 'for loop' to increment g
g changes with respect to considered system
for i=1:g
for j=1:14
something
end

回答(1 个)

Stephan
Stephan 2019-2-25
编辑:Stephan 2019-2-25
Hi,
use numel function:
for i = 1:numel(g)
Best regards
Stephan
  5 个评论
kavya kolipakula
kavya kolipakula 2019-2-25
g is generator bus data taken from 14bus sytem
in for loop i used power injection equations. my requirement is power injections at generator buses
Stephan
Stephan 2019-2-25
编辑:Stephan 2019-2-25
Can you explain a bit more clear? Usually if a vector changes in length, numel is the right choice. If this is not what you want to do, please explain.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by