Filter löschen
Filter löschen

Error using odearguments Vector Length issue

15 Ansichten (letzte 30 Tage)
Matthew Gervasi
Matthew Gervasi am 15 Sep. 2024 um 20:37
Kommentiert: Matthew Gervasi am 15 Sep. 2024 um 21:02
I am not sure I understand the issue here. Any help would be appreciated
%% Initial Variables
s1=0.27; s2=1.04; s3=0.716; s4=0; s5=0; Vref=1.04; Pref=0.716;
%% Define Diferential Equations
function dsdt= pv_system(t,s)
%parameters
Ki=20; Kp=4; Kip=10; Kiq=10; Tr=0.02; TGpv=0.01; Rq=0; Rp=0.05;
Vref=1.04; Qactual=0.27; Vt=1.04;Pref=0.716;DeltaOmega=0;Pactual=0.716;
Qcmd =0.27;
%State Variables
s1=s(1); s2=s(2); s3=(s); s4=s(4); s5=s(4);
%diferential Equations
ds1dt=Ki*(Vref-s2-Rq*Qactual);
ds2dt = (1 / Tr) * (Vt - s2);
ds3dt = (1 / TGpv) * (Pref - (DeltaOmega / Rp) - s3);
ds4dt = Kip * (s3 - Pactual);
ds5dt = Kiq * (Qcmd - Qactual);
dsdt = [ds1dt; ds2dt; ds3dt; ds4dt; ds5dt];
end
%% inital Vector
s0 = [s1;s2;s3;s4;s5];
%% Time span for simulation
tspan = [0 10]; % 0 to 10 seconds
%% Solve using ode45
[t, s] = ode45(@pv_system, tspan, s0);
Error using odearguments (line 98)
PV_SYSTEM returns a vector of length 13, but the length of initial conditions vector is 5. The vector returned by PV_SYSTEM and the initial conditions vector must have the same number of elements.

Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);

Akzeptierte Antwort

Torsten
Torsten am 15 Sep. 2024 um 20:41
Bearbeitet: Torsten am 15 Sep. 2024 um 20:45
s3 = s(3)
s5 = s(5)
instead of
s3=(s)
s5=s(4)
  1 Kommentar
Matthew Gervasi
Matthew Gervasi am 15 Sep. 2024 um 21:02
Thank you so much, cant believe my dyslexia sstruck at the worst time.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by