Path: news.mathworks.com!not-for-mail
From: "El Hassan Abdel Fattah" <s8ru9@unb.ca>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Testing if vector x is twice vector y
Date: Thu, 15 Oct 2009 19:46:18 +0000 (UTC)
Organization: University of New Brunswick
Lines: 30
Message-ID: <hb7u6a$4f2$1@fred.mathworks.com>
References: <hb7r2f$8p4$1@fred.mathworks.com> <hb7sdj$8a7$1@fred.mathworks.com>
Reply-To: "El Hassan Abdel Fattah" <s8ru9@unb.ca>
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 1255635978 4578 172.30.248.37 (15 Oct 2009 19:46:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Oct 2009 19:46:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2042725
Xref: news.mathworks.com comp.soft-sys.matlab:577652


"Justin " <justink@email.unc.edu> wrote in message <hb7sdj$8a7$1@fred.mathworks.com>...
> "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

Thanks for your help. The command i'm writing goes like this: "x=all(y.*2)". I'm basically trying to get matlab to display all elements in x are twice y. my answer comes to be 1, which implies a true statement, however it is false. i know it is very simple but im not getting there for some reason. thanks again