Question: ANSWER WITH MATLAB CODE ONLY, NO OTHER PROGRAMMING LANGUAGES Write a function getpythogorean(N) that returns all of the positive integer numbers that satisfy the following

ANSWER WITH MATLAB CODE ONLY, NO OTHER PROGRAMMING LANGUAGES

Write a function getpythogorean(N) that returns all of the positive integer numbers that satisfy the following property:

x^2+y^2=z^2

where x,y,z are positive integers x<y<zN. Your function should return a 3-column matrix where each row contains numbers x,y,z satisfying the above constraints. The rows must be in increasing order of z. Do not use any loops to solve this problem. Hints: meshgrid, reshape, elementwise and, logical indexing, it takes four statements to solve this problem.

THE CORRECT ANSWER WILL RETURN THE FOLLOWING OUTPUTS EXACTLY:

>> getpythogorean(11) ans = 3 4 5 6 8 10 >> getpythogorean(20) ans = 3 4 5 6 8 10 5 12 13 9 12 15 8 15 17 12 16 20 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!