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

17 views (last 30 days)
Mahbubur Rahman
Mahbubur Rahman on 20 Apr 2016
Answered: Ruchir Kemnaik on 10 May 2016
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);
max_iter = 10;
for i =1:max_iter
mpc.bus(5,3) = mpc.bus(5,3) +5

Answers (1)

Ruchir Kemnaik
Ruchir Kemnaik on 10 May 2016
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.

Community Treasure Hunt

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

Start Hunting!