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 中查找有关 Power and Energy Systems 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by