2nd Order Nonlinear Differential Equation Solving with Newton Method

Hello,
I have a question about the spring mass system below.
I have solved this problem by hand till a final equation which is 2. order nonlinear differential equation. The equation is;
Now, ı need to solve this equation by using matlab.I have assigned logical values to parameters as my code below and simplified the equation,
clear all;
syms Theta(t);
ab=diff(Theta,2);
aa=diff(Theta);
m1=1; %kg
m2=1.5; %kg
m3=2; %kg
b1=0.5; %m
b2=1; %m
k=10; %N/m2
g=9.81; %m/s2
T=15; %N.m
F=20; %N
dx=(F/k)*cos(90-Theta);
h=b1+b2+dx;
s=sqrt((h-(b1*cos(Theta)+b2))^2+(b1*sin(Theta)^2));
c1=0.1;
c2=0.1;
ode=(m2+m3*cos(Theta).^2)*b1^2*ab-m3*b1^2*aa.^2*sin(Theta)...
*cos(Theta)+ (c1*cos(Theta).^2+c2*sin(Theta).^2)*b1^2*aa...
+(m2*g*b1*sin(Theta))+(k*(b1^2*sin(Theta)+((s*b1^2*sin(Theta))/(sqrt(s^2+2*b1^2*(1-cos(Theta))))))-T+F*b1*cos(Theta));
Now I am confused about how to solve this equation by using newton's method.
Can you help me ?

2 Comments

Newton method is used for roots finding. BUt you want to solve ODE. Am i missing something?
I wanna solve the ODE if it is possible

Sign in to comment.

Answers (1)

You can try dsolve or re-write your equations and use ode45
Express = ...
ddtheta = @(th,dth) m3*b1^2*dth^2*sin(th)*cos(th) - ...
f = @(t,u) [u(2);ddtheta(u(1),u(2))];
[t,u] = ode45(f,[0 5],[1 1]);
plot(t,u)
See more: ode45

7 Comments

Hi,
I re-writed the equation and tried to solve exactly as you suggest, but ı am getting the error 'Inputs must be floats, namely single or double.' I couldnt fix it. Here is my code.
clear all
syms Theta
m1=1; %kg
m2=1.5; %kg
m3=2; %kg
b1=0.5; %m
b2=1; %m
k=10; %N/m2
g=9.81; %m/s2
T=15; %N.m
F=20; %N
dx=(F/k)*cos(90-Theta);
h=b1+b2+dx;
s=sqrt((h-(b1*cos(Theta)+b2))^2+(b1*sin(Theta)^2));
c1=0.1;
c2=0.1;
aa = diff(Theta);
ab= diff(Theta,2);
ab = @(Theta,aa)m3*b1^2*aa^2*sin(Theta)...
*cos(Theta)- (c1*cos(Theta)^2+c2*sin(Theta)^2)*b1^2*aa...
-(m2*g*b1*sin(Theta))-(k*(b1^2*sin(Theta)+((s*b1^2*sin(Theta))/(sqrt(s^2+2*b1^2*(1-cos(Theta))))))*T-F*b1*cos(Theta))...
/((m2+m3*cos(Theta)^2)*b1^2)
f = @(t,u) [u(2);ab(u(1),u(2))];
[t,u] = ode45(f,[0 5],[1 1]);
plot(t,u)
I don't see this expression the same as on the picture
ab = @(Theta,aa)m3*b1^2*aa^2*sin(Theta)...
*cos(Theta)- (c1*cos(Theta)^2+c2*sin(Theta)^2)*b1^2*aa...
-(m2*g*b1*sin(Theta))-(k*(b1^2*sin(Theta)+((s*b1^2*sin(Theta))/(sqrt(s^2+2*b1^2*(1-cos(Theta))))))*T-F*b1*cos(Theta))...
/((m2+m3*cos(Theta)^2)*b1^2)
Can you explain more? what is and ? What is s?
Here f1 and f2. I substituted them into the main equation. They are linked with potential and kinetic energy gradients of the system
Hello Darova,
i need your help in solving an ODE of a Newton’s cradle consisting of a pair of pendulums with mass 1 and 2 as shown in Figure
I determinated those equations:
I dont know how to use the ODE.
close all
clear all
clc
%Initial Conditions
r = 0.05; % Radius beider Kugeln
l = 0.3; % Seillänge
m_rechts = 50; % Masse der rechten Kugel
m_links = 50; % Masse der linken Kugel
start = [pi/3;0];
phi_rechts_initial = pi/3;
phidot_rechts_initial =0;
phi_links_initial = 0;
phidot_links_initial =0;
J_rechts = (m_rechts*l^2);
J_links = (m_links*l^2);
%ts = 0.001;
%timespan = 0:ts:40;
g = 9.81;
odefun= @(t,phi) [phi(3);...
phi(4);...
-(m_rechts*g*sin(phi(1)*l))/ J_links;...
-(m_links*g*sin(phi(2)*l))/ J_rechts];
tspan=linspace(0,5);
[t, phi]= ode45(odefun,tspan,start);
plot(t, phi(:,1)*180/pi,'linewidth',2)
xlabel('time(s)','FontSize',16,'Fontname', 'Arial', 'FontWeight','bold')
ylabel('phi in degrees','FontSize',16,'Fontname', 'Arial', 'FontWeight','bold')
title('Pendulum Motion','FontSize',16,'Fontname', 'Arial', 'FontWeight','bold')
please create your own question

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 5 May 2020

Commented:

on 30 Jan 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!