Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please create a function that returns the minimum element and its index in a numeric array ( single - row vector or single - column

Please create a function that returns the minimum element and its index in a numeric array (single-row vector or single-column vector). Name your function as findMin().
The input to the function can be either a row vector, a column vector, or a scalar (of numeric data types), otherwise the function returns a vector of 2NaNs ([NaN
NaN]).
Your function returns 2 scalar values in the format of [min_val, min_idx] which represents the value and index of the minimum element, respectively. For
example, return [[21] if input is the scalar 2.
If the array contains duplicates of the minimum element, keep only the smallest index of the min_val. DO NOT return multiple indices.
You are not permitted to use| the built-in min() or max() functions. You can exploit if, for or while structures to create your functions. Any algorithm or method can be
used.
The function header is already given as function [min_val, min?idx]= findMin (input).
Function ?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Public Finance Fundamentals

Authors: K. Moeti

3rd Edition

148512946X, 9781485129462

Students also viewed these Databases questions

Question

Discuss the techniques of sales forecasting.

Answered: 1 week ago

Question

Write short notes on Marketing mix.

Answered: 1 week ago