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: for loop to find true/false and build sum and so distinguish
Replies: 10   Last Post: Apr 13, 2012 1:36 PM

Advanced Search

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

Posts: 18
Registered: 3/27/12
Re: for loop to find true/false and build sum and so distinguish
Posted: Apr 11, 2012 11:19 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> % From what I understand,
> % the above code becomes something like this:
>
> myvalue = ??; % length 16 vector, insertvalues here
> Number = ??; % scalar, insert value here
> truefalse = zeros(1,16); % initialize to all zeros (for false case)
> for i =1:16
> if myvalue(i) > Number % true case
> truefalse = 1;
> end
> end
> n=sum(truefalse); % =max 16, min 0
> if n==0
> option 1 % insert your code here
> elseif n==6
> option 2 % insert your code here
> elseif n==16
> option 3 % insert your code here
> end
>
> % The above may not be exactly what you want,
> % but its my best interpretation and
> % it should get you started.




Thanks very much to someone :o)
I am checking soon if it works, will let you know! Cheers and thanks! Markus



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.