ode45 no enough input argument

hi guys, i really need help.I have been trying to solve 3 differential equations with ODE 45, but it keeps giving the error that there are not enough input arguments.
This is my function:
function dxdt=funsystest(t,x)
%given conditions
theta1=1;
theta2T =[0.5,2];
theta2=transpose(theta2T);
%a=abs(b);
phi1=x(1)^2;
n1=norm(phi1);
phi2=[x(1),sin x(2)];
n2=norm(phi2);
%umin=0.02;
c1=5;
c2=5;
etha1=1;etha2=1;
gamma=4;
sigma=0.05;
n=0.1; kd=1;
s=0.6;
%update law
theta_cap=integral(dxdt(3));
%derivations
z1=x1; %first error
alpha1=-(c1+1)*z1-(1/4*etha)*theta_cap*n1*n1*z1;%virtual control input
alpha1dot=-(c1+1)-(1/4*etha)*theta_cap*n1*n1;
z2=x2-alpha1;%second error
v=(c2+0.5+kd)*z2+(1/2*etha2)*theta_cap*n2*n2*z2-alpha1dot*(z2+alpha1)+(1/2*etha2)*theta_cap*alpha1dot^2*n1^2*z2-alphacap*z2;
%control law
u=-(z2*v^2)/((1-s)*sqrt(z2^2*v^2+n^2));
% udot=diff(u);
%update law
%tuning function
tau1=(gamma/4*etha1)*n^2*z1^2-gamma*sigma*theta_cap;
dxdt=zeros(2,1);
dxdt(1) = x(2)+ phi1*theta1;
dxdt(2) = u + phi2*theta2;
dxdt(3)=tau1+(gamma/2*etha2)*n2^2*z2^2+alpha1dot^2*n1^2*z2^2;
dxdt = dxdt';
end
and this is my odefile
%odefile%
clc ;
close all;
timerange = [0 3];
IC = [0.5;0;0];
[t,x]=ode45('funsystest',timerange,IC);
subplot(2,2,1);
plot(t,x(:,1));
subplot(2,2,2);
plot(t,x(:,2));
subplot(2,2,3);
plot(t,x(:,3));
And this is the error i get.
Error using sin
Not enough input arguments.
Error in funsystest (line 12)
phi2=[x(1),sin x(2)];
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in test (line 9)
[t,x]=ode45('funsystest',timerange,IC);
>>

回答(1 个)

The error in this line:
Error in funsystest (line 12) phi2=[x(1),sin x(2)];
As you can see, the sin is all by itself with no input argument, hence the error. Maybe this is what you meant:
phi2=[x(1), sin(x(2))];

13 个评论

thanks......also wanted to know what does the remaining error meant....?
You still get an error ?
@Bilin Mathew: what is the complete error message?
this is the error.....
i am doing project on adaptive backstepping where dxdt(3) is the update law...
@Bilin Mathew: please do not give screen shots. Please give the error message as text.
Bilin Mathew's "Answer" moved here:
Undefined function or variable 'theta_cap'.
Error in funsys (line 48) alpha1=-(c1+1)*z1-(1/4*etha1)*theta_cap*n1*n1*z1;%virtual control input
Error in odearguments (line 90) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in func (line 9) [t,x]=ode45('funsys',timerange,IC);
The code you have posted so far is not your current code. The line involving theta_cap that you posted before is before line 30, not nearly as late as line 48, so we must assume that your code before that point has been changed in important ways.
Note: your posted code has
theta_cap=integral(dxdt(3));
which is not valid, as integral() requires three parameters, the first being a function handle and the second being the lower bound as a numeric scalar and the third being the upper bound as a numeric scalar.
Furthermore, at that point in the code, no value has been assigned to dxdt .
Hello , am trying to use backstepping in matlab and found error.
Function dx= backstepping(t,x)
x1dot=z-c1(x1);
zdot=c1(z)-c1^2(x1)+u;
x2=z-c1(x1);
u=c1^2(x1)-x1-(x2+c1(x1))(c1+1);
dx=x1dot+zdot;
end
[t,x]=ode45(@backstepping,[0,10],2);
plot(t,x)
grid on
Please help
Error: File: backstepping.m Line: 3 Column: 16
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in backstepping_s (line 1)
[t,x]=ode45(@backstepping,[0,10],2);

请先登录,再进行评论。

类别

Community Treasure Hunt

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

Start Hunting!

Translated by