title: Matrices: Write a function in MATLAB that returns all of the positive integer numbers that satisfy the following property
body: <p>Write a function getpythogorean(Z) that returns all of the positive integer numbers that satisfy the following property, for all positive integers less than or equal to Z:</p>
  
  <p>x^2 + y^2 = z^2</p>
  
  <p>The function is not supposed to contain any loops.</p>
  
  <p>Here is a sample input/output</p>
  
  <blockquote>
    <blockquote>
      <p>getpythogorean(20)</p>
      
      <p>ans = [3   4   5; 6   8  10; 5  12  13; 9  12  15; 8  15  17; 12  16  20]</p>
    </blockquote>
  </blockquote>
  
  <p>So essentially, you get a value of Z and output the x's, y's, and z's that result in z &lt; 20</p>
  
  <p>As of right now this is what I have:</p>
  
  <blockquote>
    <p>function [out] = getpythogorean(Z)</p>
    
    <p>[X,Y] = meshgrid(1:Z,1:Z);</p>
    
    <p>W = sqrt((X.^2)+(Y.^2));</p>
    
    <p>end</p>
  </blockquote>
  
  <p>Now I need to somehow filter the values of W and save their locations to reference back to the X and Y matrices for the output.  Supposedly this can be done in 4 lines of code.</p>
  
  <p>Any suggestions on how to tackle this would be greatly appreciated.</p>
  
  <p>Thank You!</p>