Solve systems of eqns

조회 수: 1 (최근 30일)
Sergio Manzetti
Sergio Manzetti 2017년 12월 8일
댓글: Sergio Manzetti 2017년 12월 12일
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