Hi,
i am trying to solve for the displacement of a spring & mass with rotating eccentric mass in X and Y directions.
If i solve it using the following code:
[t,y] = ode45(@odefun, tspan, ic);
function dydt = odefun(t,y) %SDOF (Uncoupled) Forced (Unbalance), Undamped
dydt = zeros(4,1); dydt(1) = y(2); dydt(2) = -(k/M)*y(1)+(m/M)*e*w^2*cos(w*t); dydt(3) = y(4); dydt(4) = -(k/M)*y(3)+(m/M)*e*w^2*sin(w*t); end
I get one result (which seems incorrect for the second equation).
If i solve it using the following code (which effectively separates it into two independent ODEs:
[t,y] = ode45(@odefun, tspan, ic);
function dydt = odefun(t,y) %SDOF (Uncoupled) Forced (Unbalance), Undamped dydt = zeros(2,1); dydt(1) = y(2); dydt(2) = -(k/M)*y(1)+(m/M)*e*w^2*cos(w*t); end
[t2,y2] = ode45(@odefun2, tspan, ic2);
function dydt2 = odefun2(t,y2) dydt2 = zeros(2,1); dydt2(1) = y2(2); dydt2(2) = -(k/M)*y2(1)+(m/M)*e*w^2*sin(w*t); end
I get a different result, which seems more in line with what i expect.
Why would i get different results for these two methods?
See attached images..
Any help would be greatly appreciated!
Best Answer