EDUCBA

EDUCBA

MENUMENU
  • Explore
    • Lifetime Membership
    • All in One Bundles
    • 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 Dot

Matlab Dot

Updated March 14, 2023

Matlab Dot

Definition of Matlab Dot

MATLAB DOT function is used for getting the dot product of specific inputs. Input data can be scalar, vector, matrices, or multidimensional arrays. If the input arguments are scalar in nature then the dot function give the scalar dot product. Let A and B be vectors and to get dot product using dot function then they must have the same length. And if input arguments are matrices or multidimensional arrays, then they must have the same size. This function is used for the dot product of real vectors as well as dot product of real vectors.

ADVERTISEMENT
Popular Course in this category
MATLAB Course Bundle - 5 Courses in 1 | 3 Mock Tests

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax:

C = dot(A,B)
C = dot(A,B,dim)

How does Matlab Dot do?

This function is used for calculating dot product of input arguments. The input arguments can be scalar, vector, real or complex values. And it can be in any format like matrices or multidimensional arrays. There are simple steps to calculating dot product and the steps are as follows.

Step 1: – Load the data into a variable or into an array

Step 2: – Use dot function with proper syntax calculating dot product of

Input data.

Step 3: – Execute the code to run the program.

Examples

Let us see the example related to the dot function.

Example #1

In this example, we calculate the dot product of the multidimensional arrays by using the dot function. so first we load the input data that is multidimensional arrays ‘R’ and ‘P’ respectively. ‘R = cat(3,[1 1;1 1],[12 13;14 15],[6 7;8 9]) ;’ this line load the multidimensional arrays ‘R’ and ‘P = cat(3,[2 2;2 2],[0 1;2 3],[14 5; 6 17]) ;’ this line load the multidimensional arrays ‘P’. If R and P are matrices or multidimensional arrays, then they must have the same size. After that, we used the dot function to calculate the dot product of the multidimensional arrays. ‘Q = dot(R,P,3)’ this syntax of the dot function is used to calculate the dot product of the multidimensional arrays. Here 3 indicates the third dimension (dim = 3) to calculate the dot product of R and P along the dimension. The result is stored in variable Q. Then we execute the code to get output.

Code:

clc;
clear all;
close all;
R = cat(3,[1 1;1 1],[12 13;14 15],[6 7;8 9]);
P = cat(3,[2 2;2 2],[
0 1;2 3],[14 5; 6 17]);
Q = dot(R,P,3)

Output:

matlab dot 1

Example #2

Let us see another example related to the dot function. In this example, we calculate the dot product of the complex number by using the dot function. So first we load the input data that are complex numbers into variables ‘P’ and ‘Q’ respectively. “P = [3+i 4-i 5+i -2-i];” this line load the complex number in to variables P and ‘Q = [4-i 4-2i 3+2i 4+3i]; this line load the complex number in to variables Q. After that, we used the dot function to calculate the dot product of the complex number. ‘R = dot(P,Q)’ this syntax of the dot function is used to calculate the dot product of the complex number. The result is stored in variable R. Then we execute the code to get output.

Code:

clc;
clear all;
close all;
P = [3+i 4-i 5+i -2-i];
Q = [4-i 4-2i 3+2i 4+3i];
R = dot(P,Q)

Output: 

matlab dot 2

Example #3

Let us see one more example related to the dot function. In this example, we calculate the dot product of the matrix by using the dot function. So first we load the input data that is number into matrix ‘P’ and ‘Q’ respectively. “P = [9 8 7;6 5 4;2 3 1];” this line load the number in to matrix P and ‘Q = [3 8 5;1 1 1;3 2 1] ;’ this line load the number in to matrix Q. After that, we used the dot function to calculate the dot product of the matrix. ‘R = dot(P,Q)’ this syntax of the Matlab dot function is used to calculate the dot product of the matrix. The result is stored in matrix R. Then we execute the code to get output.

Code:

clc;
clear all;
close all;
P = [9 8 7;6 5 4;2 3 1];
Q = [3 8 5;1 1 1;3 2 1];
R = dot(P,Q)

Output: 

example matlab 3

Conclusion

In this article, we saw the concept of the Matlab dot function. Basically, this function is used for calculating dot product of input arguments. Then saw syntax related to the Matlab dot function and how it is used in Matlab code. Also, we saw some examples related to the Matlab dot function.

Recommended Articles

This is a guide to Matlab Dot. Here we discuss the Definition of Matlab Dot, How to do Matlab Dot with different examples with code. You may also have a look at the following articles to learn more –

  1. Matlab Variables
  2. Matlab Sort
  3. Matlab Annotation
  4. Matlab Autocorrelation
ADVERTISEMENT
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
ADVERTISEMENT
MICROSOFT AZURE Course Bundle - 15 Courses in 1 | 12 Mock Tests
63+ Hour of HD Videos
15 Courses
12 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
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
ADVERTISEMENT
INFORMATICA Course Bundle - 7 Courses in 1
47+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
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
  • Blog as Guest
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

© 2023 - 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

Let’s Get Started

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

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?

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

🚀 Cyber Monday Reloaded Price Drop! All in One Universal Bundle (3700+ Courses) @ 🎁 90% OFF - Ends in ENROLL NOW