0
$\begingroup$

I'm having trouble representing the following as an equation

 Ids[Vgs_,Vds_,Vtn_,kn_] := \[Piecewise]    0   Vgs < Vtn
                             kn * ((Vgs-Vtn) * Vds - 1/2 * Vds^2)   Vgs >= Vtn && Vds < Vgs - Vtn
                             kn/2* (Vgs - Vtn)^2    Vgs >= Vtn && Vds >= Vgs - Vtn




 ModeOfOperation[Vgs_, Vds_, Vtn_, kn_] := \[Piecewise] "Cutoff"    Vgs < Vtn
                                                         "Triode"   Vgs >= Vtn && Vds < Vgs - Vtn
                                                         "Saturation"   Vgs>= Vtn && Vds >= Vgs - Vtn




 Rd = 0.2
Vin = 5
eq1 = Ids[Vin, V0, 1 , 1] = (5 - 2 - V0)/Rd

Solve[eq1, V0] // N

I've already defined Rd =.2 and Vin = 5. But I get the following error:

"5.(3-V0) is not a quantified system of equations and inequalities."

and

"5(3. -1.V0) is not a quantified system of equations and inequalities"

Why is eq1 not a valid expression? I understand what I'm trying to do is use the values for Vin, Rd and select the right equation from the piecewise for the left side and then solve for V0 using the right hand side.

$\endgroup$
4
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Nov 13, 2014 at 17:24
  • 1
    $\begingroup$ Try to use == instead of = $\endgroup$
    – Peltio
    Nov 13, 2014 at 17:42
  • $\begingroup$ reference.wolfram.com/language/ref/Equal.html $\endgroup$
    – george2079
    Nov 13, 2014 at 17:43
  • $\begingroup$ I tried eq1 = Ids[Vin,V0,1,1] == (5-2-V0)/Rd but its just returning True... $\endgroup$
    – nitiger
    Nov 13, 2014 at 17:45

2 Answers 2

0
$\begingroup$

Your Piecewise functions should be written as follows

Ids[Vgs_, Vds_, Vtn_, kn_] :=
  Piecewise[{
    {0, Vgs < Vtn},
    {kn*((Vgs - Vtn)*Vds - 1/2*Vds^2), Vgs >= Vtn && Vds < Vgs - Vtn},
    {kn/2*(Vgs - Vtn)^2, Vgs >= Vtn && Vds >= Vgs - Vtn}}];

ModeOfOperation[Vgs_, Vds_, Vtn_, kn_] :=
  Piecewise[{
    {"Cutoff", Vgs < Vtn},
    {"Triode", Vgs >= Vtn && Vds < Vgs - Vtn},
    {"Saturation", Vgs >= Vtn && Vds >= Vgs - Vtn}}];

Rd = 0.2;
Vin = 5;
eq1 = Ids[Vin, V0, 1, 1] == (5 - 2 - V0)/Rd;

Solve[eq1, V0][[1]]

{V0 -> 1.85857}

$\endgroup$
1
  • $\begingroup$ Thanks. I'm still learning Mathematica and the "scoping" (right side blue line) was also a huge source of my issues but I finished my assignment. Thank you for your help. Marius too. $\endgroup$
    – nitiger
    Nov 13, 2014 at 19:19
0
$\begingroup$

An equation is of the form lhs == rhs. When you write eq1 = (5 - 2 - V0)/Rd you just set the "value" of eq1.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.