help me please, i really want to run this code but i have a trouble: don't have enough argument
% This script accepts the values for the independent variables bs and ga
% and also a flag indicating which model should be used. x(1) is the
% position of the buoy. x(2) is the velocity of the buoy. x(3), x(4) and
% x(5) are the three currents. The outputs are t, x and Pout, which is the
% output power.
% Refer to Section 2 in the final report
function [t,x,Pout] = Simulation(bs,ga,flag)
% run simulation
[t,x] = ode45(@(t,x) LPM_3Phase(t,x,bs,ga,flag), [0 350], [0 0 0 0 0]);
% calculate power
RL = 7.5; %Ohm
v(:,1) = x(:,3)*RL;
v(:,2) = x(:,4)*RL;
v(:,3) = x(:,5)*RL;
Pin = x(:,3).*v(:,1) + x(:,4).*v(:,2) + x(:,5).*v(:,3);
Pout = Pin.*0.85;
end
function dx = LPM_3Phase(t,x,bs,ga,flag)
dx = zeros(5,1);
p = 6;
q = 1;
m = 3;
N = zeros(1,3);
for i = 1:3
N(i) = 82*p*q;
end
L = 0.432; %m
taup = L/p; %m
taut = taup./(m*q); %m
% bs = 0.016; %m
bt = taut - bs; %m
% ga = 0.002; %m
Kc = taut*(5*ga+bs)/(taut*(5*ga+bs)-bs^2);
geq = Kc*ga;
hm = 0.006; %m
Br = 1.2; %T
mu0 = 4*pi*10^(-7);
Hc = 905000;
phi = zeros(1,3);
for i = 1:3
phi(i) = (Br*hm*Hc*mu0)/(hm*Hc*mu0 - geq*Br);
end
if flag == 1 % Simple
um = 2.2; %m/s
uav = 2/pi*um; %m/s
T = 12.6; %s
Ra = 1.5; %Ohm
Ls = 0.115; %H
RL = 7.5; %Ohm
Ms = 4; %number of armatures
Ws = 0.2; %m
KE = Ms*Ws*N(i)*phi(i)*uav;
% u = um*sin(omegam*t);
u = um.*sin(2*pi.*t./T);
du = 2*pi.*um./T*cos(2*pi.*t./T);
e = zeros(1,3);
e(1) = KE*cos(pi.*x(1)./taup)*u;
e(2) = KE*cos(pi.*x(1)./taup - 2*pi/3)*u;
e(3) = KE*cos(pi.*x(1)./taup - 4*pi/3)*u;
v = zeros(1,3);
v(1) = x(3)*RL;
v(2) = x(4)*RL;
v(3) = x(5)*RL;
F = zeros(1,3);
for i = 1:3
F(i) = N(i).*phi(i).*pi./taup.*sin(pi.*x(1)./taup).*x(i + 2);
end
dx(1) = u; % u
dx(2) = du;
elseif flag == 2 % Complex
um = 2.2; %m/s
uav = 2/pi*um; %m/s
T = 12.6; %s
A = 4; %um*T/(2*pi); %m
Ra = 1.5; %Ohm
Ls = 0.115; %H
RL = 7.5; %Ohm
Ms = 4; %number of armatures
Ws = 0.2; %m
KE = Ms*Ws*N(i)*phi(i)*uav;
% u = um*sin(omegam*t);
u = x(2);
e = zeros(1,3);
e(1) = KE*cos(pi.*x(1)./taup).*u;
e(2) = KE*cos(pi.*x(1)./taup - 2*pi/3).*u;
e(3) = KE*cos(pi.*x(1)./taup - 4*pi/3).*u;
v = zeros(1,3);
v(1) = x(3)*RL;
v(2) = x(4)*RL;
v(3) = x(5)*RL;
F = zeros(1,3);
for i = 1:3
F(i) = N(i).*phi(i).*pi./taup.*sin(pi.*x(1)./taup).*x(i + 2);
end
rho = 1025; %kg/m^3
g = 9.81; %m/s^2
a = 0.5; %m
b = 1; %m
h = 10; %m
M = 1000; %kg
mr = 289; %kg
Rr = 16; %Ns/m
Rv = 717; %Ns/m
dx(1) = x(2);
dx(2) = -((Rr + Rv).*(x(2) - 2.*pi.*A./T.*cos(2.*pi.*t./T)) +...
rho.*g.*pi.*a.^2.*(x(1) - A.*sin(2.*pi.*t./T)))./(M + mr);
end
dx(3) = (e(1) - v(1) - x(3)*Ra)/Ls;
dx(4) = (e(2) - v(2) - x(4)*Ra)/Ls;
dx(5) = (e(3) - v(3) - x(5)*Ra)/Ls;
end

 Accepted Answer

darova
darova on 2 Jul 2020

0 votes

You probably run the code in a wrong way. Here are some changes

2 Comments

thank you so much with love from Vietnam, you have just saved my final thesis, you are my hero
im just doing my job

Sign in to comment.

More Answers (1)

J. Alex Lee
J. Alex Lee on 1 Jul 2020

0 votes

your error is probably not with the ODE line, but actually running "Simulation", which you are not supplying any arguments to at the command prompt, but it expects 3 arguments: bs, ga, flag

1 Comment

i need more detail sir, what i need to change?

Sign in to comment.

Products

Tags

Asked:

on 1 Jul 2020

Commented:

on 3 Jul 2020

Community Treasure Hunt

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

Start Hunting!