I am using ode45 to solve an equation.
Follwing line is from the parent file where I call my function. I am passing all the required parameters in my function.
[t,x] = ode45(@(t,x) eqns_v8(t,x,xg,para),t,x0);
In my function file, I am using collect(), subs() and eval() . The collect() function is taking to long to run. Is there any substitute to the way I coded it??
sets = [x(2) ; 1/(Md*tan(theta)+Mw*Phi)*(-(Phi*Psi+Ks*tan(theta))*x(1)+Phi*Psi*eval(subs(collect(xg,t)))+(Md*g+Ks*y_bar)*sign(x(1)))];
xg is sym which contains a part of equation which I want to use. Here is the way I got xg. This part is coded in parent file and xg is passed in my function as argument.
syms t;ag = (F*sin(Omega*t))/Mw; % Ground Acceleration
xg = int(int(ag));
I want to use the equation which I get after double intergration in another equation, Is there any other way ? Any help is welcome, Thanks in advance.
Best Answer