9 views (last 30 days)

Hi everyone,

I have the following equation of motion in a system of 6 equations of motion, which are solveed using ode45.

dy(6)=(-kr*(y(5)+L*y(11))+b*(-kr*(y(6)+L*y(12)))-m*Fload*FractionY)/mcd;

All the parameters (kr, L, b, m, Fload and mcd) are defined in the beggining of the code.

The FractionY parameter, though is calculated using the following integral

x=(0:2.513274e-6:2*pi)'; % [rad] for numeric intergration

Y=(((oc)*(r*cos(x)-y(5))-ob*r*cos(x)+y(6))/(((((oc)*(r*cos(x)-y(5))-ob*r*cos(x)+y(6)))^2+(-oc*(r*sin(x)-y(5))+ob*r*sin(x))^2)^0.5))'; %[-] dimensionless function

FractionY =(1/(2*pi))*trapz(x,Y); % [-] Numeric Intergraiton

In which oc, ob are funcions that are defined in the beggining of the script.

I want for every value of y(5), y(6) the FractionY term to be calculated again and after solve the system of equations.

Currenlty i created the following script in order to use FractionY as an external function, without any success.

function FractionY=ffy(y)

global cdspeed fwspeed FrictionFractionY x oc ob Y

oc=((cdspeed*2*pi)/60)';

ob=((fwspeed*2*pi)/60)';

x=(0:2.513274e-6:2*pi)'; % [rad] for numeric intergration

Y=(((oc)*(r*cos(x)-y(5))-ob*r*cos(x)+y(6))/(((((oc)*(r*cos(x)-y(5))-ob*r*cos(x)+y(6)))^2+(-oc*(r*sin(x)-y(5))+ob*r*sin(x))^2)^0.5))';

FrictionFractionY =(1/(2*pi))*trapz(x,Y);

end

And in my main code i define Fraction as :

FractionY=ffy(y)

How can i make it work?

Thank you in advance

Jeremy Marcyoniak
on 28 Feb 2020

function FractionY=ffy(y)

Did you save this function as FractionY.m or as ffy.m? Because as it's written, the function is actually ffy. If the file save name is different than the function name it won't work.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.