Integration of a system of differential equations MATLAB

爱⌒轻易说出口 提交于 2019-12-25 08:57:33

问题


I am a fairly new Matlab user which I had to explore to numerically integrate a system of differential equations. Now I am trying to resolve a simple equation but which gives me a "lambertw" output.

(s - 1) * exp(-s) = k

Therefore, for a given k, with k < exp(2) I should get approximately two different values of "s". Here is the bit of code I use for this task (using symbolic toolbox):

%%Hopf bifurcation calculations
syms s
solve((s-1) * exp(-s) == k, s)
%uhopf = s*k 

And the output:

1 - lambertw(0, -(3*exp(1))/25)

After looking at some examples I tried to get an explicit solution with no success:

syms x
x=solve('(s-1)*exp(-s) == k')

Finally, my question is how do I change the result given in the first place into a simple numerical value that fir a given k would give me s1 and s2. Any hint or help would be much appreciated ! I am still looking at some other examples.


回答1:


If I understand your question correctly, you can use the eval() function to evaluate the string to retrieve a simple numerical example.

e.g.

char s;
char k;
A=solve('(s-1) * exp(-s) = k', 'k=exp(1)');

sol_s=A.s(1);
sol_k=A.k(1);

ans=eval(sol_s)


来源:https://stackoverflow.com/questions/20054132/integration-of-a-system-of-differential-equations-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!