Solve systems of eqns

3 Ansichten (letzte 30 Tage)
Sergio Manzetti
Sergio Manzetti am 8 Dez. 2017
Kommentiert: Sergio Manzetti am 12 Dez. 2017
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 Kommentare
Karan Gill
Karan Gill am 11 Dez. 2017
What's your MATLAB version on the computer?
Sergio Manzetti
Sergio Manzetti am 12 Dez. 2017
Hi Karan, it's
MATLAB Version 9.2 (R2017a)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Birdman
Birdman am 8 Dez. 2017
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 Kommentare
Birdman
Birdman am 8 Dez. 2017
I have no further idea about it Sergio, so that's it from me :)
Sergio Manzetti
Sergio Manzetti am 8 Dez. 2017
Bearbeitet: Sergio Manzetti am 8 Dez. 2017
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sergio Manzetti
Sergio Manzetti am 8 Dez. 2017
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 Kommentare
Birdman
Birdman am 8 Dez. 2017
Do you mind if I look at this at weekend?
Sergio Manzetti
Sergio Manzetti am 8 Dez. 2017
Bearbeitet: Sergio Manzetti am 8 Dez. 2017
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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by