ode45 error: must return a column vector

4 次查看(过去 30 天)
Hi there!
I have seen in previous posts that this problem has an easy solution, but I cannot work it out in my code. I would appreciate any help. Before reading my code, please note that:
  • My objective is to solve the ED_LuGre equation introducing every element in vector g, but I keep getting the "must return column vector" message.
  • FR is a 121x1 vector obtained from previous operations, but I have included here just the first three elements for testing purposes.
  • The initial condition for the x variable is always x0=0.
  • I saw in other posts that placing "p=p(:);" at the end of my function would solve the problem, but if I do that I get the following message:
@(T,X)ED_LUGRE(T,X,V,S0,I) returns a vector of length 14641, but the length of initial conditions vector is 121. The vector returned by @(T,X)ED_LUGRE(T,X,V,S0,I) and the initial conditions vector must have the same number of elements.
The function:
function p=ED_LuGre(t,x,v,s0,g)
p=v-(s0*v*x)/g;
end
The code:
%2-Friction
%Forces&speeds
Fs=295743*9.81;
mu=0.7;
FR=[1233915.62500000;1233564.47063588;1233213.43415869]
Fc=mu*FR;
v=80.8333333;
vs=12.5;
%ED constants
s0=1;
s1=0.1487;
s2=0.0038;
%Internal friction function
g=Fc+(Fs-Fc)*exp(-abs((v/vs)^2));
%ED solution
tf=3;
tspan=[0 tf];
sz=size(g);
x0=zeros(sz(1),sz(2));
for i=g;
m2=@(t,x) ED_LuGre(t,x,v,s0,i);
[t,x]=ode45(m2,tspan,x0);
end

回答(1 个)

Stephen23
Stephen23 2018-10-12
编辑:Stephen23 2018-10-12
p = v-(s0.*v.*x)./g;
You need to learn about the differences between matrix operations and array operations:

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by