フィルターのクリア

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