Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: a problem of &#8220;if&#8230;else&#8221; statement
Date: Wed, 13 Apr 2011 10:06:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <io3sic$9kk$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1302689164 9876 172.30.248.38 (13 Apr 2011 10:06:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 13 Apr 2011 10:06:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1636294
Xref: news.mathworks.com comp.soft-sys.matlab:721612

Hello,

I have a problem of &#8220;if&#8230;else&#8221; statement.
For instance, I have a data set bellow.
A	B	C	D	E	F	G
1	2	7	3	9		
2	1	4	6	10		
1	2	7	9	11		
						
						

A	B	C	D	E	F	G
1	2	7	3	9	7	9
2	1	4	6	10	6	4
1	2	7	9	11	7	11
  
I want first data set to turn into second data set. There are complex conditions to determine the column F and column G.
Condition 1: numbers in column A determines whether column F or column G is filled with the number in column C. That is, if column A =1, then fills column F with numbers in column C; otherwise, fills column G with numbers in column C.  
Ex1: when A1=1, F1=C1=7; 
Ex2: when A2=2, G2=C2=4 
After condition 1 is satisfied, either column F or column G is left empty, and then do condition 2.
Condition 2: If numbers in column B =1, then fill the empty column (F or G) with numbers in column D; otherwise, fill the empty column (F or G) with numbers in column E.   
Ex1: when (condition1) A1=1 and when (condition2) B1=2, G1=E1=9; 
Ex2: when (condition1) A2=2 and when (condition2) B2=1, F1=D1=6; 
Can someone tell me how to do this? Thanks!
Sincerely,
Yihui