KannonX
KannonX

Reputation: 15

Integration of a system of differential equations MATLAB

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.

Upvotes: 0

Views: 179

Answers (1)

xyz
xyz

Reputation: 407

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)

Upvotes: 0

Related Questions