3 Replies - 352 Views - Last Post: 24 July 2013 - 06:54 PM Rate Topic: -----

#1 TurboST2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 11-November 11

[Matlab] Non-Linear Differential Equations

Posted 23 July 2013 - 09:43 AM

Ok, I need some help getting this code to work properly. I've exhausted all my know-how and got as far as I could. I'm going to post a link to my assignment as opposed to typing it all out and just paste what code I've come up with so far.

Here is the link to the theory. This is where the equations I'll be using are defined. (EQ-1 and EQ-2) I'll also post an image of the equations so you don't have to really go to this page if you don't want.
https://docs.google....dit?usp=sharing

Here is the actual assignment.
https://docs.google....dit?usp=sharing

Posted Image
Posted Image

ok, so I know I need two functions for each differential equation. Here are the functions I wrote:

Function 1: (For Part 1)
function [THWdot] = dsysEQ1(t,THW)

g=9.8;
l=10;

% x -->TH
% y -->W
x=THW(1,1);
y=THW(2,1);

xdot=y*(t);
ydot=(-g/l)*sind(x*(t));

THWdot(1,1)=xdot;
THWdot(2,1)=ydot;
end


Function 2: (For Part 2)
function [THWdot] = dsysEQ2(t,THW)

g=9.8;
l=10;

% x -->W
% y -->TH
x=THW(1,1);
y=THW(2,1);

A=[0,1;(-g/l),0];
B=[y;x];

THWdot=A*THW+B;
end



Here is my script. I haven't been able to get it to work for the first function and haven't begun writing script to utilize the other function or for labeling plots and such. I don't need help with plotting and if I can get some help writing script that makes the first function work, I should be able to finish the rest of it from there.

tSPAN=[0,60];
IC1=[0.25;0];
IC2=[1.50;0];

[t,THW]=ode45(@dsysEQ1,tSPAN,IC1);


plot(t,THW)
axis([0,60,-1,1])




Thank you for any help offered.

Is This A Good Question/Topic? 0
  • +

Replies To: [Matlab] Non-Linear Differential Equations

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10464
  • View blog
  • Posts: 38,781
  • Joined: 27-December 08

Re: [Matlab] Non-Linear Differential Equations

Posted 23 July 2013 - 10:04 AM

How doesn't it work? What specific problems or errors are you encountering?
Was This Post Helpful? 0
  • +
  • -

#3 TurboST2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 11-November 11

Re: [Matlab] Non-Linear Differential Equations

Posted 23 July 2013 - 10:09 AM

Running it in the current state outputs:

Posted Image

The output should look like:
Posted Image

Only without the linearized solultion. So I should only be seeing a blue sin wave that doesn't increase/decrease frequency. Currently I'm outputting two sin waves that are increasing in frequency. Something I'm doing isn't right.
Was This Post Helpful? 0
  • +
  • -

#4 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1329
  • View blog
  • Posts: 4,555
  • Joined: 19-February 09

Re: [Matlab] Non-Linear Differential Equations

Posted 24 July 2013 - 06:54 PM

Hi, I think that theta will be in radians so you wont use sind.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1