problem using command solve?!

1 Ansicht (letzte 30 Tage)
Sasi
Sasi am 14 Feb. 2012
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

Antworten (1)

Friedrich
Friedrich am 14 Feb. 2012
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 Kommentare
Sasi
Sasi am 14 Feb. 2012
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 am 14 Feb. 2012
Oh I find my mistake, tanx Friedrich. ;)

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