PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, June 28, 2022

[FIXED] How to plot the graph using MATLAB (or not matlab))?

 June 28, 2022     function, graph, matlab, ode, plot     No comments   

Issue

I've got the function fi(ϕ)=γi+sin(2⋅sinϕ) for i=1,2 where γ1=0.01 and γ2=0.02

ϕ1(0)=0.1 and ϕ2(0)=0.2

ϕ1/dt=f1(ϕ)+d⋅sin(ϕ2−ϕ1)

ϕ2/dt=f2(ϕ)+d⋅sin(ϕ1−ϕ2)

where d=0.1

So there should be something like for example this table:

t     | ϕ1  | ϕ2
0.00  | 0.1 |0.2
0.01  | ... |...
0.02  | ... |...
...
100.00| ... | ...

And so using the received values it's needed to plot a graph by the coordinates

So the question is how to plot the function ϕ2(ϕ1) on the the following graph using MATLAB? enter image description here


Solution

So the story of the system might be that you start with two uncoupled and slightly different equations

ϕ1/dt=f1(ϕ1)
ϕ2/dt=f2(ϕ2)

and connect them with a coupling or exchange term sin(ϕ2-ϕ1),

ϕ1/dt=f1(ϕ1)+d⋅sin(ϕ2−ϕ1)
ϕ2/dt=f2(ϕ2)+d⋅sin(ϕ1−ϕ2)

In a matlab script you would implement this as

y0 = [ 0.1; 0.2 ];
[T,Y] = ode45(eqn,[0, 100], y0);

plot(Y(:,1),Y(:,2));

function dy_dt = eqn(t,y)
  d = 0.1;
  g = [ 0.01; 0.02 ];
  f = g+sin(2*sin(y));
  exch = d*sin(y(2)-y(1));
  dy_dt = f+[d;-d];
end%function

which gives almost a diagonal line ending at [pi; pi]. With a stronger coupling constant d this becomes slightly more interesting.

You can give the parameters as parameter arguments, then you have to declare them via odeset in an options object, or use anonymous functions to bind the parameters in the solver call.



Answered By - Lutz Lehmann
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing