dan, I love you
@dan815 the file I have so far...it's basic, but that's all there is according to the example I was given... Only the task is to set r=1 and K=20 fixed which I was trying to do but the code keeps going whacko
if I remove r =1 and K=20, it's fine, but that's not what my goal is.
function f=ram(ry,y,K) f=ry(1-y/K);
well what do u wanna do to it
i dont see anything wrong with it
the task issss Solve the logistic DE dy/dt= ry(1-y/K) with r=1, K=20 % initial conditions y(0)= 5, 10, 15, 20, 25, (use a for loop) % plotting the solutions on the same figure for t in [0 10]
ok so rewrite the equatio now
u are missing * sign in there
which I noticed there are three variables, r,y, and K. If I do something like function f=ram(r,y,K) f=ry(1-y/K); K=20; r=1; it won't work. if I do function f=ram(ry,y,K) f=ry(1-y/K); it works but I need to have K=20 and r=1 fixed and that's not what is going on here If I do function f=ram(ry,y,K) f=ry(1-y/K); K=20; r=1; Matlab whines
and ry is not a paremeter is it
isnt it r*y*(1-y)/K)
star sign? oh shxxx
one sec
is ry 1 variable?
matlab needs to make their fonts bigger I swear
well I saw r y and K. I thought it was 3?
hold on refine your function with a t input, u need that when u use ode45
so it's t y K?
anyway >> ram(1,1, 20) ans = 0.9500 >> if I just solve XD
OH WAIT. hold on
you cant do that, this is just dy/dt, its only telling u the slope
btw ode45 is just a nurmerical method, our prof made us once write the code behind ode45 and the 90 or something its pretty straight forwad just different step sizes for the approximations
pft ... doing ram(1,y,20) on the code makes it scream
so if u are ever having trouble u can just write your own numerical method and it shud be fine
but I need a graph...
yeah okay
wait lets start over...
k
the task issss Solve the logistic DE dy/dt= ry(1-y/K) r=1, K=20 % initial conditions y(0)= 5, 10, 15, 20, 25,(use a for loop) % plotting the solutions on the same figure for t in [0 10]
mhm but there's r y and K in there and we have to let it be fixed at r=1 and K=20
function f=ram(t,y) r=1 K=20 f=r*y*(1-y/K); end
function f=ram(t,y) f=r*y*(1-y/K); K=20; r=1; end ?
[tv f]=ode45('ram',[0 5],1); Undefined function or variable "r". Error in ram (line 2) f=r*y*(1-y/K); Error in odearguments (line 88) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ... I will kill this thing
the example code for the graph is [tv f]=ode45('fun',[0 5],1); plot(tv,f,'-') title('y''=-ty/sqrt(2-y^2), y(0)=1, t in [0, 5]') grid axis([0 5 0 1]) so I'm just doing the first two for now with [tv f]=ode45('ram',[0 5],1); plot(tv,f,'-') and I'm getting messed up
yup proof I need glasses... I was aiming to type, dan I need you. x.x omg fml not my night
does it gotta look something like that
getting therer my scripts were running wild
yeah that graph is right...
okay heres the code i used so far
function out=usukicode() for i=[5,10,15,20,25] timerange=[0 10]; initialcond=i [t,y]=ode45(@ram,timerange, initialcond) plot(t,y) hold all; end end function f=ram(t,y) f=y.*(1-y./20); end
all in 1 file and named it usukicode.m
u can make that forloop a little more classy by i=5:5:25
ok, but what happens if r =2?
ok if u wanna pass that in too then
do u have to be able to pass it in? or u just wanna see with a new r
hold on let me try get r = 2 on this one ^_^ and if I crash I'll let you know.
a faster convergence
wtf all I got is just one graph T___T!
oh u want it in differnt graph?
no all lines have to be in one graph... why do I only have 1?
lol what even is that
save and pass usukicode(r) for r=1
oh i see initial cond is not 1
its i
XD! told ya matlab needs to have bigger fonts
yeah
what the rabbit.. if I input 2 into the function, the code displays a red warning
its working for me
maybe u shud define the ram function in another file instead of under the code like i did
i have it defined in 2 files so im not sure which instance its refering to
oh like a secondary
gotcha
got em function out = nike() for i=[5,10,15,20,25] timerange=[0,10] initialcond=i [t,y]=ode45(@card,timerange,initialcond) plot(t,y) hold all; end end function f=card(t,y) f=2*y*(1-y/20) end
looks like the graphs are retracting and the 20 is the equilibrium
it has something to do with the population... eh I can type that later.
xlabel time ylabel population is missing but that's ok. I can always fix it... I know that the original problem has 2 equlibriums 0 and K and the graphs have something to do with the population when it's going towards the equilibrium or something like that
yep it does
there is a saturation point for this ode it can be used to model some population growths
do you know what a bifurcation graph is?
i dunno what bifucation means
but the main things to observe on your graph is there is a point where its increasing exponentially then decreasing exponentially
just like population growths, when u are far from the lands supporting population u will increase like a normal interest rate growth function
but as u get closed to the saturation point the growth rate goes lower and lower and evnetually decays
closer*
oh ok ya i know this ode :)
and then the population is messed up
what about graphing stability?
0 is a unstable point
i dunno what u call it exactly but
its the one where things diverge away from
yeah but do you graph by hand x)
u wanna graph what happens at 0?
ya
add more inital conditions then
but a different function
like dx/dt = x(x^2-a^2) besides x =0,-a,a which are the equilibrium points... how do I graph it manually?
graph what exactly?
Join our real-time social learning platform and learn together with your friends!