How to run a while/for loop for a matpower case file?

8 次查看(过去 30 天)
For the case9.m file on matpower I want to change the "Pd" (power) of a bus continuously (suppose 90:1:200), and see the results using the runpf fuction. I've tried several ideas but none of them is working. I did this one , but it is not changing the value in the case9.m file. What can I do?
mpc = loadcase(case9);
mpc.bus(5,3)
max_iter = 10;
for i =1:max_iter
mpc.bus(5,3) = mpc.bus(5,3) +5
runpf
end

回答(1 个)

Ruchir Kemnaik
Ruchir Kemnaik 2016-5-10
It is my understanding that you want to change the “Pd”(power) of a bus continuously and see the results using “runpf” function. However, when you change the power of the bus, you are not able to see the updated results.
Replace the “runpf” command inside the “for” loop with “runpf(mpc)” to display the updated results. The initial data in “mpc” struct variable comes from the hardcoded data in “case9.m” file. The changes made inside the “for” loop affects only the “mpc” struct variable which is in the current workspace. The values in “case9.m” are unchanged. So, when “runpf” is called without any input arguments, it reads the data from “case9.m” by default which is the reason the updated values are not displayed in the results.

类别

Help CenterFile Exchange 中查找有关 Simulation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by