Difference between revisions of "MATLAB talk:Logical Masks"

From PrattWiki
Jump to navigation Jump to search
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Hi this is Everett Loving.
+
*Hello,
When a logical mask is scanning a matrix of numbers, is it possible to ask the mask to check for two conditions? For example:
+
My question is: What's the difference between using logical masks in a function file and then calling it in a script file vs. writing an anonymous function for it in the script vs. not using an anonymous function in a script? When would you use each case? Also, can you use an anonymous function in a function file?
Something like
+
 
variable = (condition && condition) .*value +...
+
{{unsigned|sjz3}}
          (condition) .....
+
 
 +
*Hi this is Everett Loving.
 +
When a logical mask is scanning a matrix of numbers, is it possible to ask the mask to check for two conditions? For example, something like:
 +
 
 +
      variable = (condition && condition) .*value +...
 +
                  (condition) .....
 +
{{unsigned|ejl23}}
 +
:*Absolutely - see in the GPA example how there are things like <source lang=matlab>
 +
(70<=Grade & Grade<80) * (2.0)
 +
</source>that has two conditions. Note, though, that masks don't really "scan" so much as they perform all calculations at once.  [[User:DukeEgr93|DukeEgr93]] 01:37, 20 September 2012 (EDT)

Latest revision as of 01:39, 5 October 2012

  • Hello,

My question is: What's the difference between using logical masks in a function file and then calling it in a script file vs. writing an anonymous function for it in the script vs. not using an anonymous function in a script? When would you use each case? Also, can you use an anonymous function in a function file?

—Preceding unsigned comment added by sjz3 (talkcontribs)

  • Hi this is Everett Loving.

When a logical mask is scanning a matrix of numbers, is it possible to ask the mask to check for two conditions? For example, something like:

      variable = (condition && condition) .*value +...
                 (condition) .....

—Preceding unsigned comment added by ejl23 (talkcontribs)

  • Absolutely - see in the GPA example how there are things like
    (70<=Grade & Grade<80) * (2.0)
    
    that has two conditions. Note, though, that masks don't really "scan" so much as they perform all calculations at once. DukeEgr93 01:37, 20 September 2012 (EDT)