﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?application progid="SMath Studio Desktop" version="0.99.7251.32800"?>
<worksheet xmlns="http://smath.info/schemas/worksheet/1.0">
  <settings ppi="96">
    <identity>
      <id>90f102e3-0b7c-4e94-9a5c-74b0ca356115</id>
      <revision>6</revision>
    </identity>
    <calculation>
      <precision>4</precision>
      <exponentialThreshold>5</exponentialThreshold>
      <trailingZeros>false</trailingZeros>
      <significantDigitsMode>false</significantDigitsMode>
      <roundingMode>0</roundingMode>
      <fractions>decimal</fractions>
    </calculation>
    <pageModel active="true" viewMode="0" printGrid="false" printAreas="true" simpleEqualsOnly="false" printBackgroundImages="true">
      <paper id="9" orientation="Portrait" width="827" height="1169" />
      <margins left="39" right="39" top="49" bottom="49" />
      <header alignment="Center" color="#a9a9a9">&amp;[DATE] &amp;[TIME] - &amp;[FILENAME]</header>
      <footer alignment="Center" color="#a9a9a9">&amp;[PAGENUM] / &amp;[COUNT]</footer>
      <backgrounds />
    </pageModel>
    <dependencies>
      <assembly name="SMath Studio Desktop" version="0.99.7251.32800" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
      <assembly name="Math Region" version="0.99.7251.32800" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
      <assembly name="SpecialFunctions" version="1.12.7251.32800" guid="2814e667-4e12-48b1-8d51-194e480eabc5" />
      <assembly name="TextRegion" version="1.11.7251.32800" guid="485d28c5-349a-48b6-93be-12a35a1c1e39" />
    </dependencies>
  </settings>
  <regions type="content">
    <region left="18" top="18" width="579" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">https://en.smath.com/forum/yaf_postst17703findunread_choose-minimum-positive-number.aspx</p>
      </text>
    </region>
    <region left="18" top="54" width="142" height="27" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">A</e>
          <e type="operand">1</e>
          <e type="operand">3</e>
          <e type="operator" args="1">-</e>
          <e type="operand">4</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="operator" args="1">-</e>
          <e type="operand">1</e>
          <e type="operand">5</e>
          <e type="function" args="7">mat</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="18" top="90" width="238" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">First approach:vectorize the condition.</p>
      </text>
    </region>
    <region left="54" top="126" width="164" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Elements bigers than one</p>
      </text>
    </region>
    <region left="288" top="126" width="124" height="100" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">Z</e>
          <e type="operand">A</e>
          <e type="operand">1</e>
          <e type="operator" args="2">&gt;</e>
          <e type="function" args="1">vectorize</e>
          <e type="function" args="1">transpose</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">0</e>
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="operand">0</e>
          <e type="operand">5</e>
          <e type="operand">1</e>
          <e type="function" args="7">mat</e>
        </result>
      </math>
    </region>
    <region left="54" top="207" width="179" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Augment with the 1..n range</p>
      </text>
    </region>
    <region left="288" top="207" width="344" height="100" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">B</e>
          <e type="operand">Z</e>
          <e type="operand">1</e>
          <e type="operand">A</e>
          <e type="function" args="1">length</e>
          <e type="function" args="2">range</e>
          <e type="function" args="2">augment</e>
          <e type="function" args="1">eval</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">0</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="operand">3</e>
          <e type="operand">1</e>
          <e type="operand">4</e>
          <e type="operand">0</e>
          <e type="operand">5</e>
          <e type="operand">5</e>
          <e type="operand">2</e>
          <e type="function" args="12">mat</e>
        </result>
      </math>
    </region>
    <region left="54" top="288" width="218" height="40" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Find the values where first column 
is true (one) and take the indices:</p>
      </text>
    </region>
    <region left="288" top="288" width="278" height="45" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">C</e>
          <e type="operand">B</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="function" args="3">findrows</e>
          <e type="operand">2</e>
          <e type="function" args="2">col</e>
          <e type="bracket">(</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">3</e>
          <e type="operand">4</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" args="4">mat</e>
        </result>
      </math>
    </region>
    <region left="54" top="342" width="164" height="40" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Take the minumun of the 
matrix values</p>
      </text>
    </region>
    <region left="288" top="342" width="96" height="35" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">A</e>
          <e type="operand">C</e>
          <e type="function" args="2">el</e>
          <e type="function" args="1">min</e>
        </input>
        <result action="numeric">
          <e type="operand">2</e>
        </result>
      </math>
    </region>
    <region left="54" top="387" width="71" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">All in one:</p>
      </text>
    </region>
    <region left="90" top="423" width="555" height="60" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">A</e>
          <e type="operand">A</e>
          <e type="operand">1</e>
          <e type="operator" args="2">&gt;</e>
          <e type="function" args="1">vectorize</e>
          <e type="function" args="1">transpose</e>
          <e type="operand">1</e>
          <e type="operand">A</e>
          <e type="function" args="1">length</e>
          <e type="function" args="2">range</e>
          <e type="function" args="2">augment</e>
          <e type="function" args="1">eval</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="function" args="3">findrows</e>
          <e type="operand">2</e>
          <e type="function" args="2">col</e>
          <e type="function" args="2">el</e>
          <e type="function" args="1">min</e>
        </input>
        <result action="numeric">
          <e type="operand">2</e>
        </result>
      </math>
    </region>
    <region left="18" top="495" width="273" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Another approach: use an auxiliary function.</p>
      </text>
    </region>
    <region left="54" top="531" width="278" height="214" color="#000000" fontSize="10">
      <math>
        <description active="true" position="Top" lang="eng" width="563">
          <p fontName="Arial">Find(M,c(x)) returns a vector with the indices of the elements in M that verify the condition c(x) for x in M, 
or zero if there aren't any one.</p>
        </description>
        <input>
          <e type="operand">M</e>
          <e type="operand">1</e>
          <e type="function" args="1">c</e>
          <e type="function" args="2">Find</e>
          <e type="operand">n</e>
          <e type="operand">0</e>
          <e type="operator" args="2">:</e>
          <e type="operand">r</e>
          <e type="operand">0</e>
          <e type="operator" args="2">:</e>
          <e type="operand">v</e>
          <e type="operand">0</e>
          <e type="operator" args="2">:</e>
          <e type="operand">1</e>
          <e type="operand">3</e>
          <e type="function" args="5">mat</e>
          <e type="operand">x</e>
          <e type="operand">M</e>
          <e type="operand">n</e>
          <e type="operand">n</e>
          <e type="operand">1</e>
          <e type="operator" args="2">+</e>
          <e type="operator" args="2">:</e>
          <e type="operand">x</e>
          <e type="function" args="1">c</e>
          <e type="operand">1</e>
          <e type="operator" args="2">≡</e>
          <e type="operand">0</e>
          <e type="function" args="2">try</e>
          <e type="operand">v</e>
          <e type="operand">r</e>
          <e type="operand">r</e>
          <e type="operand">1</e>
          <e type="operator" args="2">+</e>
          <e type="operator" args="2">:</e>
          <e type="function" args="2">el</e>
          <e type="operand">n</e>
          <e type="operator" args="2">:</e>
          <e type="operand">continue</e>
          <e type="function" args="3">if</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" args="4">line</e>
          <e type="function" args="3">for</e>
          <e type="operand">v</e>
          <e type="operand">3</e>
          <e type="operand">1</e>
          <e type="function" args="5">line</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="54" top="792" width="69" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Condition</p>
      </text>
    </region>
    <region left="216" top="792" width="97" height="26" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">x</e>
          <e type="function" args="1">c</e>
          <e type="operand">x</e>
          <e type="operand">1</e>
          <e type="operator" args="2">&gt;</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="54" top="828" width="55" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Indices</p>
      </text>
    </region>
    <region left="216" top="828" width="184" height="45" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">v</e>
          <e type="operand">A</e>
          <e type="operand">x</e>
          <e type="function" args="1">c</e>
          <e type="function" args="2">Find</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">3</e>
          <e type="operand">4</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" args="4">mat</e>
        </result>
      </math>
    </region>
    <region left="54" top="882" width="68" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Elements</p>
      </text>
    </region>
    <region left="216" top="882" width="72" height="45" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">A</e>
          <e type="operand">v</e>
          <e type="function" args="2">el</e>
        </input>
        <result action="numeric">
          <e type="operand">4</e>
          <e type="operand">2</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" args="4">mat</e>
        </result>
      </math>
    </region>
    <region left="54" top="945" width="67" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">Minimum</p>
      </text>
    </region>
    <region left="216" top="945" width="96" height="35" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">A</e>
          <e type="operand">v</e>
          <e type="function" args="2">el</e>
          <e type="function" args="1">min</e>
        </input>
        <result action="numeric">
          <e type="operand">2</e>
        </result>
      </math>
    </region>
    <region left="54" top="990" width="71" height="24" color="#000000" fontSize="10">
      <text lang="eng">
        <p fontName="Arial">All in one:</p>
      </text>
    </region>
    <region left="216" top="990" width="193" height="39" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">A</e>
          <e type="operand">A</e>
          <e type="operand">x</e>
          <e type="function" args="1">c</e>
          <e type="function" args="2">Find</e>
          <e type="function" args="2">el</e>
          <e type="function" args="1">min</e>
        </input>
        <result action="numeric">
          <e type="operand">2</e>
        </result>
      </math>
    </region>
    <region left="18" top="1044" width="60" height="24" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">Alvaro</e>
        </input>
      </math>
    </region>
  </regions>
</worksheet>