How to use MATLAB input Function

How to use MATLAB input Function
Here, in this tutorial I will explain you the importance and the procedure about How to use MATLAB input Function. The one of the main advantage of getting the data from the user is, the algorithm becomes generic in this way. The different users can get different types of results from the same program according their requirements. The user has to enter the input on the command window and can get the desired results according to the given input.Getting User Data
- First of all open your MATLAB software and go to the editor in MATLAB.
- Write a simple code in editor as shown below.
clc
x=input('Enter the value of x = ');
y=input('Enter the value of y = ');
x+y
- Move to the command window and observe the results.
- As you Run the program you will automatically move to the command window.
- Command window will ask to enter the value of the first variable, which is x in this case.
- The result of the above program is shown in the figure below:
- DC Motor Speed Control in MATLAB.
- DC Motor Direction Control in MATLAB.
- Stepper motor Speed Control in MATLAB.
- Stepper Motor Direction Control in MATLAB.
- After entering the value of x command window will ask to enter the value of the second variable, which is y in this case.
- The figure shown below displays the above results.
- As you enter the value of y and press Enter, you will be able to see the result of the addition of the both of the variables.
- The result is shown in the figure below.
- Till now, I have performed addition operation on the variables whose values are given by the users and the program shows the different results for each user.
- You can also perform a lot of other operations on these variables.
- Here, I am going to perform basic mathematics operations on these two variables.
- The code for multiplication operation is shown below.
clc %clearing command window
x=input('Enter the value of x = ');%takes the value of x from the user
y=input('Enter the value of y = ');%takes the value of y from the user
product = x*y %performing multiplication
- The input MATLAB code will look something as shown in below figure:
- The result on the command window is shown in the figure below.
- Now, I am going to perform the division operation on the both of the variables.
- The source code for the division operation is shown below.
clc %clears comand window
x=input('Enter the value of x = '); %takes the value of x from the user
y=input('Enter the value of y = '); %takes the value of y from the user
product = x/y %performing division operation
- The result of the above source code is shown in the figure below.
- Similarly you can perform a lot of other operations on the variables whose values are given by the user.
- So, that was the brief discussion about How to use MATLAB input Function.
- Here's the video in which I have explained in detail How to use MATLAB input Function:
×
![]()





































































