Path: news.mathworks.com!not-for-mail
From: "prabhakaran m" <prabha.gahon@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: if loop condition
Date: Sun, 20 May 2012 02:50:22 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <jp9m5e$jbq$1@newscl01ah.mathworks.com>
Reply-To: "prabhakaran m" <prabha.gahon@gmail.com>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1337482222 19834 172.30.248.35 (20 May 2012 02:50:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 20 May 2012 02:50:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2438980
Xref: news.mathworks.com comp.soft-sys.matlab:768347


i want to use this condition to find f(x)
f(x) = 1 + 2x for x between -1 and 0 and f(x) = 1 - 2x for x between 0 and 1

clear all
N=41;
x=linspace(-1,1,41)
theta=-pi:2*pi/(N-1):pi;

if x >-1 & x<=0
    y=1+2*x
else
    y=1-2*x
end		

i am getting the y values wrongly.	what is the mistake i am doing. pls correct me