Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Determine Max without using max inbuilt function

Subject: Determine Max without using max inbuilt function

From: Ar

Date: 2 Sep, 2013 14:49:06

Message: 1 of 4

How would I, without using the ‘max’ inbuilt function, write a function that takes a vector as function input and returns the maximum value and the index at which the
maximum value occurs. Where the function should work for input vectors of any length.
I figured the function should start as follows:

function [max_value,index] = mymax(x)

Subject: Determine Max without using max inbuilt function

From: TideMan

Date: 2 Sep, 2013 19:58:39

Message: 2 of 4

On Tuesday, September 3, 2013 2:49:06 AM UTC+12, Ar wrote:
> How would I, without using the max inbuilt function, write a function that takes a vector as function input and returns the maximum value and the index at which the
>
> maximum value occurs. Where the function should work for input vectors of any length.
>
> I figured the function should start as follows:
>
>
>
> function [max_value,index] = mymax(x)

I can't think of a reason you'd want to do this, unless it's a homework assignment.
If so, don't come here asking us to help you cheat.
Do your own homework.

Subject: Determine Max without using max inbuilt function

From: Nasser M. Abbasi

Date: 2 Sep, 2013 20:53:59

Message: 3 of 4

On 9/2/2013 9:49 AM, Ar wrote:
> How would I, without using the ‘max’ inbuilt function, write a
>function that takes a vector as function input and returns the
>maximum value and the index at which the
> maximum value occurs. Where the function should work for input vectors of any length.
> I figured the function should start as follows:
>
> function [max_value,index] = mymax(x)
>

someone was asking that also just 2 days ago.

http://www.mathworks.com/matlabcentral/newsreader/view_thread/331357

just need to add one line or may be 2, to return the index
as well.

--Nasser

Subject: Determine Max without using max inbuilt function

From: Steven_Lord

Date: 3 Sep, 2013 15:30:40

Message: 4 of 4



"Ar " <ariq.quazifc@gmail.com> wrote in message
news:l028h2$pj4$1@newscl01ah.mathworks.com...
> How would I, without using the max inbuilt function, write a function
> that takes a vector as function input and returns the maximum value and
> the index at which the
> maximum value occurs. Where the function should work for input vectors of
> any length.
> I figured the function should start as follows:
>
> function [max_value,index] = mymax(x)

If you and Nicholas are in the same class (as seems likely, since the text
of your post and Nicholas's are nearly identical), perhaps you can both ask
your professor for help as the cyclist recommended.

http://www.mathworks.com/matlabcentral/answers/86118-alternative-to-max-built-in-function

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us