Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!r15g2000prh.googlegroups.com!not-for-mail
From: swgillan <swgillan@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: if statements
Date: Fri, 10 Oct 2008 23:36:06 -0700 (PDT)
Organization: http://groups.google.com
Lines: 44
Message-ID: <786c8902-db40-465d-90c1-b38a0dadd6f0@r15g2000prh.googlegroups.com>
References: <gcmi9m$lbj$1@fred.mathworks.com>
NNTP-Posting-Host: 24.108.200.25
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1223706967 27135 127.0.0.1 (11 Oct 2008 06:36:07 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 11 Oct 2008 06:36:07 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: r15g2000prh.googlegroups.com; posting-host=24.108.200.25; 
	posting-account=oG0_2QoAAADs2vBCPqAYFyNKpnhzubZa
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) 
	Gecko/2008092417 Firefox/3.0.3,gzip(gfe),gzip(gfe)
Bytes: 2157
Xref: news.mathworks.com comp.soft-sys.matlab:494662


First of all comments help identify your intention you are trying to
do with you code.
> =A0my code:
>
> %setting parameter
> vtn =3D 0.75;
> vds =3D [0.2 2.5 0];
> vgs =3D [2 2 0];
> knp=3D[200*10^-6 300*10^-6];
> kp=3Dknp*10;
> i =3D 1; len =3D length (vgs);
> while i <=3D len
> =A0 =A0 x(i)=3Dvds(i)*(vgs(i)-vtn-vds(i)/2);
> =A0 =A0 i =3D i + 1;
> end

This part of your code will not work as someone mentioned above
because you are treating the vector id like a scalar. Also it looks
like you are creating an infinite loop here as your while has not exit
condition.

> while
> id=3Dkp.'*x

> if id =3D=3D 0
This like above will only be true of all the elements in id are zero.
> =A0 =A0 disp('cutoff')
> else
> =A0 =A0 disp('saturation')
> end

This, to me, makes a lot more sense.

id=3Dkp.*x;
%Check to see if the value of id is saturated
for i =3D1:len(id)
    if id(i) =3D 0
        disp('cutoff');
   else
        disp('saturated');
   end
end

Hope this helps.