ode45 error: must return a column vector
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!