problem using command solve?!

1 次查看(过去 30 天)
Sasi
Sasi 2012-2-14
Hi
I have a problem using command solve. when I write these commands on the command window, I get 4 answers for m equation.
ka=2;
landa=4;
syms x
y = (ka/landa)*((x/landa)^(ka-1))* (2^(-(x/landa)^ka));
LO = diff(y);
sf=solve(LO,x)
but when i use these same codes in my m.file I have get errors regarding mupad. Moreover I can access to the first answer of sf, not all of them.
Does anybody why this happen?
tnx
sasi

回答(1 个)

Friedrich
Friedrich 2012-2-14
Hi,
when I run your code from the command window I get two solutions:
ka=2;
landa=4;
syms x
y = (ka/landa)*((x/landa)^(ka-1))* (2^(-(x/landa)^ka));
LO = diff(y);
sf=solve(LO,x)
sf =
(2*2^(1/2))/log(2)^(1/2)
-(2*2^(1/2))/log(2)^(1/2)
Running it in a script or functions works fine too. What error do you get? Which version of MATLAB are you using?
  2 个评论
Sasi
Sasi 2012-2-14
Hi,
yes you are right. I am so sorry.
if you run it again with:
ka=2.22;
landa=0.90;
then you will get 4 answers.
But I dont get all the answers when I use them in function. I use MATLAB R2011a.
Thank you very much
Sasi
Sasi 2012-2-14
Oh I find my mistake, tanx Friedrich. ;)

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by