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!

