Using eval function for execute a power flow with DC system embedded
Mostrar comentarios más antiguos
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 comentario
Stephen23
el 29 de Oct. de 2020
"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.).
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Power and Energy Systems en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

