I am trying to wrtie Shaft_speed as a function of time , so the shaft speed should increase to from 1 to 4000 as time goes on.
I also need the initial condition values X,Y and Z of the last speed to be the new intial condition of the new shaft speed. so far i have:
clc,clear,close allJ=3.37e-5; %inertia of rotor (kg/m2)
K1=0.7243; %Linear stiffness coef (N.m/rad)
K3=1409.7; %Nonlinear stiffness coef (N.m/rad3)
f=0.005;Zeta=0.05;%damping ratio
Cmech=2*Zeta*(sqrt(K1/J))*J; %mechanical damping coef
Rint=82;Rload=82;ECF=sqrt(1.9e-6/Rint); %electromagnetic coupling factor
L=160e-3;%Inductance (mH)
%initial conditions
X = 0; %initial displacement
Y = 0; %initial Velocity
Z = 0; %initial .....
%shaft speed in RPM
Shaft_speed=0:1000;%shaft speed in rad/s
Rad_speed=Shaft_speed.*((2*pi)/60); %freq of harmonic fluctuations
w=2.*Rad_speed;w_Hz=w./2*pi; %convert to Hertz
nt=1./w_Hz; Time=0:nt/100:100*nt;Iter=10;for r=1:Iter[t,q]=ode45(@duf,Time,[X Y Z]);X=q(end,1);Y=q(end,2);Z=q(end,3);Max_values(r) = max(q(:,1))plot(t,q(:,1),'k')xlabel('TIme,s')ylabel('Relative Displacement, Rad')gridendmax=max(Max_values)function qdot=duf(t,q) % q_ddot+(Cmech/J)*q_dot+(K1/J)*q+(K3/J)*x^3=f*(w^2)*cos(w*t)
J=3.37e-5; %inertia of rotor (kg/m2)K1=0.7243; %Linear stiffness coef (N.m/rad)K3=1409.7; %Nonlinear stiffness coef (N.m/rad3)f=0.005;Zeta=0.05;%damping ratioCmech=2*Zeta*(sqrt(K1/J))*J; %mechanical damping coefRint=82;Rload=82;ECF=sqrt(1.9e-6/Rint); %electromagnetic coupling factorL=160e-3;%Inductance (mH)%shaft speed in RPMShaft_speed=0:1000;%shaft speed in rad/sRad_speed=Shaft_speed.*((2*pi)/60); %freq of harmonic fluctuations w=2.*Rad_speed;w_Hz=w./2*pi; %convert to Hertzqdot(1)=q(2);qdot(2)=f.*w.^2.*cos(w.*t)-(Cmech/J).*q(2)-(K1/J).*q(1)-(K3/J).*q(1).^3- ECF.*q(3);qdot(3)=(-ECF.*q(2)-(Rint+Rload).*q(3))./L;qdot = [qdot(1);qdot(2);qdot(3)];end
but i geet keep getting '-Error using odearguments (line 21)
When the first argument to ode45 is a function handle, the tspan argument must have at least two elements.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in mainduffing (line 33)
[t,q]=ode45(@duf,Time,[X Y Z]);'
Thanks in advance
Best Answer