Using eval function for execute a power flow with DC system embedded
显示 更早的评论
I use the eval function to store the matpower case that its control variable has been assigned and call matpower to run the power flow
....
eval(['savecase (''case_ieee30_test', num2str(i), '.mat'', baseMVA, bus, gen, branch)']);
eval(['initial_results_',num2str(i),'=runpf(''case_ieee30_test',num2str(i), '.mat'')']);
eval(['initial_losses_',num2str(i),'=sum(real(get_losses(initial_results_',num2str(i),')))']);
....
All of the code works great,but when I want to execute another power flow which DC system embedded I use 'runacdcpf' function. But it didn't work at all.. What could the problem? . I am using the following lines of code:
eval(['savecase (''case_ieee30_test', num2str(i), '.mat'', baseMVA, bus, gen, branch)']);
eval(['initial_results_',num2str(i),'=runacdcpf(''case_ieee30_test','case5_stagg_MTDCslack' ,num2str(i), '.mat'')']);
eval(['initial_losses_',num2str(i),'=sum(real(get_losses(initial_results_',num2str(i),')))']);
the error were:
Error using loadcase (line 246)
loadcase: specified MAT file does not exist
Error in runacdcpf (line 109)
[baseMVA, bus, gen, branch] = loadcase(caseac);
Error in pso_orpd_edit (line 63)
eval(['initial_results_',num2str(i),'=runacdcpf(''case_ieee30_test','case5_stagg_MTDCslack' ,num2str(i),
'.mat'')']);
Your help greatly appreciated!!
1 个评论
Stephen23
2020-10-29
"What could the problem?"
Numbered variables, i.e. initial_results_1, initial_results_2, etc., are a sign that you are doing something wrong.
Putting meta-data (e.g. pseudo-indices) into variable names is a sign that you are doing something wrong.
Both of these mean that you force yourself into writing slow, complex, inefficient, buggy code to access your data:
The neat, simple, and very efficient approach is to use indexing with one array (e.g. numeric, cell, table, etc.).
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Power and Energy Systems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

