How to use MATLAB input Function

matlab input,input matlab,matlab input function, how to use matlab inputHello everyone! I hope you all will be fine and having fun. Today, I am going to share my knowledge about How to use MATLAB input Function. In this tutorial I would like to tell you about the importance of getting data from the user in MATLAB. If you want to display the data to users, you need to get data from them as well according their requirements. I hope you have read How to use MATLAB ? In this way the same source code written in MATLAB will give different result according to the requirements of the each user. So, in other words the source code becomes generic in this way. As we run the program, command window of the MATLAB asks user to enter the desired input. The results on this window are generated according to the Matlab input given by the user. You should also have a look at Laplace Transform in MATLAB.

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:
Note:You should also have a look at these MATLAB projects as well: Getting User Data in MATLAB, Getting User Data using MATLAB, Getting User Data with the MATLAB, how to Get User Data in MATLAB, how to Get User Data using MATLAB, How to Get User Data with the MATLAB, Getting user input in MATLAB, obtaining user input in MATLAB, How to get user input using MATLAB tool.
  • 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:
So, that is all from the tutorial How to use MATLAB input Function. I hope you enjoyed this tutorial. If you find any sort of problem, you can ask in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. You should also have a look at Introduction to MATLAB. In my next tutorial I will elaborate that how to generate rectangular signals in MATLAB and how to manipulate them. I will further explore MATLAB in my later tutorials by making further projects on it and will share them with all of you as well. So, till then, Take Care :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir