I'm finding it difficult to execute loadcase functions using MATPOWER toolbox.

i get the error message below when i run my code.
Error Message:
>> nath
Attempt to execute SCRIPT loadcase as a function:
C:\Users\vicky brandelle\Desktop\matpower7.1\lib\loadcase.m
Error in nath (line 2)
mpc = loadcase('case15');
Code :
% Load IEEE 15-bus System Data
mpc = loadcase('case15');
% Original Power Flow Analysis
results_initial = runpf(mpc);
% Introduce On-Load Tap Changer (OLTC) at bus 5
regulated_bus = 5;
% Change the type of bus 5 to PV (V controlled, P specified)
mpc.bus(regulated_bus, BUS_TYPE) = 2;
% Define the tap limits and set the initial tap position
tap_min = 0.9;
tap_max = 1.1;
initial_tap = 1.0;
mpc.branch(end+1, :) = [regulated_bus regulated_bus 0.0 tap_min tap_max 0.0 initial_tap 0.0 0.0 0.0 0.0 0.0];
% Power Flow Analysis with OLTC
results_with_oltc = runpf(mpc);
% Display Bus Voltages
fprintf('Initial Bus Voltages:\n');
disp(results_initial.bus(:, VM));
fprintf('Bus Voltages with OLTC:\n');
disp(results_with_oltc.bus(:, VM));
% Compare Line Losses
loss_initial = sum(results_initial.branch(:, PT));
loss_with_oltc = sum(results_with_oltc.branch(:, PT));
fprintf('Initial Total Line Loss: %.2f MW\n', loss_initial);
fprintf('Total Line Loss with OLTC: %.2f MW\n', loss_with_oltc);

 채택된 답변

You have a file called loadcase.m. The code in that file is a script, not a function. So it cannot take an input argument. Yet you tried to do exactly that in this line:
mpc = loadcase('case15');
Hence it threw that error.
You forgot to attach loadcase.m so we can't check it. But I imagine the suspected fix is to add a line to the beginning of loadcase.m that looks like this:
function loadcase(filename)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by