EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab min
 

Matlab min

Priya Pedamkar
Article byPriya Pedamkar

Updated March 3, 2023

Matlab min

 

 

Definition of Matlab min

‘Min’ is function used in Matlab to find minimum or smallest value from database. This function can be applied on any type of dataset like integers, characters, floating numbers, etc. Along with type of dataset it can be applied on any dimensions of data such as arrays, vectors, two dimensional elements, three dimensional elements, etc. If values are missing in dataset then most of the times ‘NaN’ represents null values, there are two ways to apply min function on this type of datasets. First function is ‘omitnan’, which ignores Nan values and second function is ‘includenan’, which is used to include Nan values in dataset.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax:

  • min ( Input variable name )

min ( Input )

  • min ( input variable name , [ ] , dimensions )

min ( Input , [ ] , 2 )

  • min ( input variable name , [ ] , ‘ includenan ’ )

min ( Input , [ ] , ‘ includenan ’ )

  • min ( input variable name , [ ] , ’ omitnan ’ )

min ( Input , [ ] , ‘ omitnan ’ )

How min function work in Matlab?

‘Min’ function gives smallest value from given input as output. It is simple process to find smallest value from integers and floating numbers, but it is difficult and complex to calculate minimum value from characters and strings. if we apply min function on characters or strings then it works on ascii values it calculates ascii values first and then find smallest number from ascii numbers.

Examples

Let us discuss examples of Matlab Min.

Example #1

First let us consider one simple array or vector [ 20, 41, 30, 23,12, 6, 10, 45, 34 ] , which is declared as Input. These are simple integers so output after applying min function is 6.

Matlab Code:

clc ;
clear all ;
Input = [ 20, 41, 30, 23, 12, 6, 10, 45, 34 ] disp ( ' Minimum Element ' ) ;
min ( Input)

Output:

Matlab min 1

Example #2

Let us consider one example with character elements as input [ ‘ A ‘ , ‘ B ‘ , ‘ D ‘ , ‘ E ‘ ], which is declared as Input. In character and string database min function will find out ascii values first and then it will calculate smallest value .in this example ASCII values of A, B, D, E are 65, 66, 68, 69 respectively. Therefore smallest value is 65.

Matlab Code:

clc ;
clear all ;
Input = [ ' A ' , ' B ' , ' D ' , ' E ' ] disp ( ' Minimum Element ' );
min ( Input )

Output:

Matlab min 2

Example #3

Let us consider one matrix as input with three rows and three columns [ 34, 32, 67 ; 34, 21, 20 ; 45, 78, 10 ] ,which is declared as Input. If input is multidimensional then min function will work on each column individually. Therefore output of this example is 34, 21 and 10 which is illustrated in example 3 ( a ). If we want output in a different way then we can give dimensions to min function. In same example let us apply dimension as 1 then output will be 34,21 and 10 that means if dimension is one then it will work on each column individually which is illustrated in example 3 ( b ). And by considering same input if we apply dimension as 2 then it will work on each row and it will give a result on each row so output will be 32, 20, and 10, which is illustrated in example 3( c ).

Matlab Code (a)

clc ;
clear all ;
Input = [ 34, 32, 67 ; 34 , 21, 20 ; 45, 78, 10 ] disp ( ' Minimum Element ' ) ;
min ( Input )

Output:

Matlab min 3

Matlab Code ( b)

clc ;
clear all ;
Input = [ 34, 32, 67 ; 34, 21, 20 ; 45, 78,10 ] disp ( ' Minimum Element ' ) ;
min ( Input,[ ] ,1 )

Output:

Matlab min 4

Matlab Code ( c )

clc ;
clear all ;
Input = [ 34, 32, 67 ; 34, 21, 20 ; 45, 78, 10 ] disp ( ' Minimum Element ' ) ;
min ( Input,[ ] ,2 )

Output:

Matlab min 5

Example #4

In this example, we will consider one value in database which is NaN. Nan represents null values in any type of database. If there are NaN values in database and we apply min function without any instruction then automatically it will ignore the NaN value, which is illustrated in example 4(a).there are two functions in min function. One is omitnan and second is includenan. ‘omitnan’ will ignore NaN values and ‘Includenan’ will consider NaN values.

Matlab code 4 (a)

clc ;
clear all ;
Input = [ 4.5 , 6.5, 6.0, 3.4, 3.2, 1.4, 1.9, 1.2, 4.9, NaN ] disp ( ' Minimum Element ' ) ;
min ( Input )

Output:

example 4

Matlab code 4(b) –

clc ;
clear all ;
Input = [ 4.5, 6.5, 6.0, 3.4, 3.2, 1.4, 1.9, 1.2, 4.9, NaN ] disp ( ' Minimum Element ' ) ;
min ( Input , [ ] , ' includenan ' )

Output:

example 4-3

Matlab Code 4( c )

clc ;
clear all ;
Input = [ 4.5, 6.5, 6.0, 3 .4, 3.2, 1.4, 1.9, 1.2, 4.9, NaN ] disp('Minimum Element');
min ( Input, [ ], 'omitnan' )

Output:

example 4-2

Conclusion

In this article, we have seen how to apply min function on all types of datasets like arrays, vectors, two dimensional, and 3 dimensional. There is no restriction on data type while applying min function. It works on all data types.

Recommended Articles

This is a guide to Matlab min. Here we discuss the definition, How min function work in Matlab? along with the examples for better understanding. You may also have a look at the following articles to learn more –

  1. MATLAB Eigenvalues
  2. Matlab Forms
  3. Matlab plot title
  4. Matlab fplot()

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW