Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: if statement in if clause
Date: Sat, 09 Oct 2010 17:23:13 -0500
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <i8qq8f$nh7$1@news.eternal-september.org>
References: <i8qpon$65s$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 9 Oct 2010 22:27:28 +0000 (UTC)
Injection-Info: mx02.eternal-september.org; posting-host="wmrNV0dr30rreDWB/RUeVQ";
	logging-data="24103"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19PNT2sLJ71jXwG1ZAsMbfG"
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
In-Reply-To: <HIDDEN>
Cancel-Lock: sha1:+0V5KiTWKBPf56Fu8G6gtnl6vks=
Xref: news.mathworks.com comp.soft-sys.matlab:677154

Yayp Rafique wrote:
...
> My very simple question is that how can I write an if statement in the 
> if-clause of a prior if statement. this isn't like the "easy" if 
> statement where I can write the nested if statement in then-clause or 
> the else-clause. i think its better if i explain through an example what 
> I would like:
> 
> if(if(Z>0);A;else;B;end) > 0 && if(Z<0);C;else;D;end) > 0 )
     F=5
> else
       G=3
> end
> 
> although this is not the correct syntax in MATLAB this is what I would 
> like. 

Matlab has no such syntax nor way I can think of to simulate it

> The solution of "solving them the nested if statements before and 
> saving their results and then using these results" will not work because 
> I am writing a parser and I won't know the depth of nesting before hand. 
> I have to generate a MATLAB script as the output of my parser. I would 
> really appreciate feedback on how to do this.

State machine comes to mind...

--