Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need help debugging these codes. Please help me. Part 3: findNmins.m Write a function with the header [X]= findNmins (A, N ), where N is
need help debugging these codes. Please help me.
Part 3: findNmins.m Write a function with the header [X]= findNmins (A, N ), where N is a number less than the length of an array of numbers, A. First check that A is 1-D (only one row or only one column) and that N is less than the length of A - give an error if either of these are false. Next, output the N smallest elements of A. For example, if A=[7,9,5,8,3,4,6,2,1,10] and N= 3 , the output of M= find N maxes (A,N) would be M= [1,2,3] I encourage you to write your own pseudocode first, and then you can check your pseudocode by clicking on the button below Rule - you cannot use the sort or mink functions but you can use the min function for this problem Check your logic I encourage you to write your own pseudocode or flowchart first, and then you can see my pseudocode by clicking on the button below Check your function [outputvar] = findNmins ([19,24,2,3, 4,5,6,7,8,9,1,2,3,32],2) outputvar = 12 [X]=f indNmins ([19,24,2,3,4,5,6, Part 4 - lowest.m Create a function with the header [X,i]=lowest(A) that will find the lowest value of the array A and output the value in X and the index (location) of that value in i. This function should work for an array A of any length Don't get this confused with Part 3 - in Part 3 you were allowed to use the min function, now for Part 4 you are writing your own minimum function that will find both the location of the lowest value and the index of the lowest value. I suggest doing this by first assuming the first number in the array is the lowest and then comparing it with each subsequent number to see if it is greater than or less than that number. Rules - you cannot use the MATLAB sort() function and you cannot use the max () or min( ) functions (or any variations of these functions) Check your function Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started