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 NUMEL Matlab
 

NUMEL Matlab

Updated March 13, 2023

NUMEL Matlab

 

 

Introduction to NUMEL Matlab

The NUMEL function is used to count the number of array elements. It is also used to count the number of elements in the database. The NUMEL performed in MatLab is employed to search out the number of elements in an array, The result of numel is the same as the prod(size(z)). We can count any number of elements from the database, there are no such criteria or requirements for database format. Any type of database is accessible to numel functions such as arrays, vectors, or multidimensional matrices.

Watch our Demo Courses and Videos

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

Syntax:

The syntax of numel is given as follow: –

h = numel ( z )

How to Do NUMEL Matlab?

h = numel ( z )  returns the number of elements , z ,  in array h , equivalent to prod ( size ( z ) ) . In this format, h represents output variable name and z is the input variable name by using z we can pass any random database values to the function. And accordingly, it will create results in the form of several elements present at the input side.

Examples of NUMEL Matlab

Here are the following examples mentioned below.

Example #1

Let us consider one example, firstly  Matrix, and then compute it using MatLab.

In this example, we have to create a 6 – by – 6 – by-2 matrix. To create Matrix have use numel function along with the magic Matlab function.

Code:

clc;
clear all;
h = magic( 5 );
h(:,:,2)=h'
n = numel( h )

Output:

e =  magic ( n )  returns an n-by-n matrix constructed from the integers 1 through n^ 2 with equal row and column sums. In the above example magic function is used to create a 6 – by – 6 – by – 2 matrices. As per that matrix h ( : , : , 1 )  and matrix h ( : , : , 2 )  is created . and then to count the number of elements in the matrix we used numel function. And the result is the total count of elements is 50.

Numel matlab output 1

Example #2

Now let us consider the second example, we can create a cell array of character vectors, and then we can compute it to see the result in Matlab.  Here we use array a having n number of characters

Then to find how many elements are in the array we use numel Matlab function.

Code:

clc;
clear all;
d = {'Bing Cherry.',' Crab apples','orange.','Evergreen_Huckleberry'};
n =  numel( d )

Output:

Numel matlab output 2

In the above example, a cell array of character vector of fruits is given. All fruits are kept in set ‘d ’. To find the total numbers of fruits inset ‘ d ’ use Matlab function numel.

The total count of fruits inset ‘ d; is 4.

Example #3

Let us consider another example; in this example, we can create one table of student information. These table fields are like student name, roll number, weight, height, and year. We can store the number of student information and as well we can also take this student information by the user instead of giving it directly in Matlab. After generating the table we can now use the numel Matlab function to see the number of elements in that table. And the result is stored in the variable ‘ z ’.

Code:

clc;
Name = {'Ram'; 'Raju'; 'Seeta'; 'Geeta'; 'Rani'};
Roll_no = [ 40; 30; 28; 48; 19 ];
Weight  =  [ 40; 55; 65; 85; 50 ];
Height = [ 170; 169; 140; 138; 175 ];
Year =  [ 2; 4; 1; 2; 3 ];
D = table(  Roll_no , Weight , Height,  Year , ' RowNames ' ,  Name )
Z = numel( D )

Output:

Numel matlab output 3

Conclusion

In this article, we have seen how to use numel function use in Matlab. It can be applied to count the number of array elements, to count the number of elements in the database with other major terminologies in programming. By using numel function we can pass multiple parameters as well as function names to the code.

Recommended Articles

This is a guide to NUMEL Matlab. Here we discuss How to Do NUMEL Matlab and Examples along with the codes and outputs. You may also have a look at the following articles to learn more –

  1. MATLAB Exponential
  2. Matlab sym()
  3. Matlab loglog()
  4. Factorial in Matlab

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