Solve systems of eqns

3 次查看(过去 30 天)
Hi, I tried solving a system for:
if true
% code
end
eqns = h^2*[diff(y,t)+2*i*g*y+g^2==0, diff(z,t)==y];
sol = dsolve(eqns)
and get:
>> Solve_Systems_of_ODE
h = 2 g =
5
sol =
struct with fields:
z: [1×1 sym]
y: [1×1 sym]
what does this result mean really?
Thanks
  10 个评论
Karan Gill
Karan Gill 2017-12-11
What's your MATLAB version on the computer?
Sergio Manzetti
Sergio Manzetti 2017-12-12
Hi Karan, it's
MATLAB Version 9.2 (R2017a)

请先登录,再进行评论。

采纳的回答

Birdman
Birdman 2017-12-8
Hi Sergio,
syms y(t) z(t)
h=4.5;
g=4/pi;
eqns=h^2*[diff(y,t)+2*i*g*y+g^2==0,diff(z,t)==y];
sol=dsolve(eqns);
y=vpa(sol.y,4)
z=vpa(sol.z,4)
I assume that the numeric constants are the same with previous question, the struct sol actually holds the solution of these diff equation set wrt y and z respectively. Actually it has solution. Why don't you check it once more?
  5 个评论
Birdman
Birdman 2017-12-8
I have no further idea about it Sergio, so that's it from me :)
Sergio Manzetti
Sergio Manzetti 2017-12-8
编辑:Sergio Manzetti 2017-12-8
Birdman, now suddenly MATLAB online manages to reproduce the solution. I give the entire code here:
if true
% code
end
syms a h Y(theta) g x B
eqn = h^2*diff(Y,theta, 2) + (2*i*h*g)*diff(Y,theta) == g^2;
cond = Y(0) == cos(x);
Y(theta) = dsolve(eqn, cond)
and the solution is indeed:
C16 - exp(-(g*theta*2i)/h)*(C16 - cos(x)) - (g*theta*1i)/(2*h)
however, cos(x) is a constant as the variable is theta, so how do I solve this? Really not sure.

请先登录,再进行评论。

更多回答(1 个)

Sergio Manzetti
Sergio Manzetti 2017-12-8
Birdman, have a look at this
if true
% code
end
syms a h Y(theta) g x
eqn = h^2*diff(Y,theta, 2) + (2*i*h*g)*diff(Y,theta) == g^2;
cond = Y(0) == cos(x);
Y(theta) = dsolve(eqn)
This one did not complain about the condition, in fact, it even ignored it.
  3 个评论
Birdman
Birdman 2017-12-8
Do you mind if I look at this at weekend?
Sergio Manzetti
Sergio Manzetti 2017-12-8
编辑:Sergio Manzetti 2017-12-8
That is fine, I have found out that cos(x) which is invalid as an initial condition - as you correctly said, was treated as a constant by MATLAB online using that command, while MATLAB alpha on the computer did not let that be solved. This means remaking the current system to a 2D PDE problem (like you also suggested with the pdpe link) is one option, or simplify the initial conditions of the 1D problem. It appears that the latter is is sound. We'll see. Thanks, have a good weekend

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by