EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
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.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

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
SPSS Course Bundle - 14 Courses in 1 | 5 Mock Tests
34+ Hours of HD Videos
14 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
MICROSOFT AZURE Course Bundle - 15 Courses in 1 | 12 Mock Tests
62+ Hour of HD Videos
15 Courses
12 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
HADOOP Course Bundle - 32 Courses in 1 | 4 Mock Tests
125+ Hour of HD Videos
32 Courses
4 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
INFORMATICA Course Bundle - 7 Courses in 1
47+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Popular Course in this category
MATLAB Course Bundle - 5 Courses in 1 | 3 Mock Tests
 11+ Hours of HD Videos
5 Courses
3 Mock Tests & Quizzes
  Verifiable Certificate of Completion
  Lifetime Access
4.5
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

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

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

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more