Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Vector comparison using if
Replies: 4   Last Post: Nov 20, 2012 4:04 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 5,688
Registered: 2/7/05
Re: Vector comparison using if
Posted: Nov 20, 2012 3:14 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 11/19/2012 11:33 PM, Rajasekhara Madhusudan Narayana Bhatla wrote:

>> many ways to do this. One way
>>
>> ----------------
>> fs = 1000;
>> x = 1:4/fs:5;
>> Y = 4*ones(length(x),1);
>> Y(x<2) = x(x<2).^2
>> ------------------
>>
>> --Nasser

>
> Ok...got it...
> Thanks a lot.
>
> if possible can you give me some pointers as to what are other ways.
>


another way:

-------------------------
fs = 1000;
x = 1:4/fs:5;
Y = (x.^2).*(x<2)+4*(x>=2)
-----------------------

--Nasser




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.