Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Testing if vector x is twice vector y
Date: Thu, 15 Oct 2009 19:16:03 +0000 (UTC)
Organization: University of North Carolina
Lines: 27
Message-ID: <hb7sdj$8a7$1@fred.mathworks.com>
References: <hb7r2f$8p4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255634163 8519 172.30.248.37 (15 Oct 2009 19:16:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Oct 2009 19:16:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1411534
Xref: news.mathworks.com comp.soft-sys.matlab:577646


"El Hassan Abdel Fattah" <s8ru9@unb.ca> wrote in message <hb7r2f$8p4$1@fred.mathworks.com>...
> hello all,
> 
> im a university student and currently im taking a matlab course this term. i got an assignment due tomorrow and needed some help:
> 
> if we have two variables:
> 
> x = [4; 1; 4; 6; 2]
> y = [3; 9; 2; 3; 1]
> 
> question is as follows: Test if all the elements of x are twice as big as the corresponding elements in y OR any element of x is less than the corresponding element of y.
> 
> given hint: use the functions 'all( )' and 'any( )' and logic operators ('|', single vertical bar) for vectors.
> 
> Thanks for anyones help!!
> 
> Hassan

This can be done in two or 3 commands, but since it's a HW assignment I can't give you an answer and feel honorable.  I will give you some hints and you will have to do some reading and thinking.

you might want to use the help command to look up:
1.) the "mod" command
2.) "." based commands (specifically what ./ does)

Good luck.

--Justin