Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Testing if vector x is twice vector y
Date: Thu, 15 Oct 2009 15:34:28 -0500
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <hb81a3$mp1$1@news.eternal-september.org>
References: <hb7r2f$8p4$1@fred.mathworks.com> <hb7sdj$8a7$1@fred.mathworks.com> <hb7u6a$4f2$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX188yU0blwqhQHwcyCWLu5m1Kzvv+ou4ii7mYRfHR90vgPmO+TUIJzLPmYyv6Yj8J5Z1NjC9d5MvhsaTm9Zp7FUCbOpizbabx8vjHpVSmgwhiL6fFrhWyhzwhpxW/Mek6p0rixPsghRyNA==
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Thu, 15 Oct 2009 20:39:33 +0000 (UTC)
In-Reply-To: <hb7u6a$4f2$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX1/1nOeSrD08Ka9MZ/YP3D8ByzgZKhReOZU=
Cancel-Lock: sha1:XN60asKbFFT7iWGdVgtye6awyzw=
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
Xref: news.mathworks.com comp.soft-sys.matlab:577665


El Hassan Abdel Fattah wrote:
> "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)
>>
...
> 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

Well, first stop and figure out how you would solve the problem by hand. 
  I don't think the above expression would fit into that if you think it 
thru that way.  IOW, what do you instinctively do in determining whether 
your answer is right for the first part, then the second?

I'll make the hint that I don't see mod() coming into play here, at 
least the way I'd approach it but agree w/ "./" ... :)

--