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

Matlab ginput

Updated March 6, 2023

Matlab ginput

 

 

Introduction to Matlab ginput

Matlab provides different types of functions to the user; ginput is one of the functions provided by Matlab. By using the ginput () function, we can determine the coordinators for any point within the specified area, such as Cartesian, polar, and geographic axes; as per our requirement, we can determine the coordinators. In Matlab, this is the default function; sometimes we miss the axes, which means in the program, we don’t specify the axes at that time ginput () function automatically creates the object of Cartesian axes. On the other hand, if we specify the axis point, then Matlab returns the specified coordinator.

Watch our Demo Courses and Videos

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

Syntax

[X_Coordinator,Y_Coordinator] = ginput (num)
[X_Coordinator,Y_Coordinator] = ginput
[X_Coordinator,Y_Coordinator, button] = ginput(__________)

Explanation

There are multiple syntaxes for the ginput () function in Matlab. In the above first syntax, we specify the X and Y coordinator and ginput (num) identify the coordinator for num point within the specified area such as Cartesian, polar, and geographic axes. After identifying the area, we need to select the point by using a mouse or keyboard.

In the second syntax, we used to return an unlimited number of points.

By using the third syntax, we can manually select the coordinator, or we can say point.

How ginput works in Matlab?

Now let’s see how the ginput () function works in Matlab as follows.

To use the ginput () function, we need to follow the different steps as follows.

First, we need to identify the Plot coordinator and points within the specified area:

This is the very first step in Matlab to use the ginput () function; in this step, we just need to identify the four different points in a set of axes with the help of the ginput () function. For the selection of points, we need to move the cursor to the specified location that we want and after that, press the mouse button or keyboard button.

Another way to select the coordinator is that return button:

This is another way to select the coordinator. In this method, we need to identify the coordinator that we want by using the ginput () function and set it into the axes, after moving the cursor to desired location those we want and press the keyboard button or mouse button.  In the final stage, we use the return mouse button or any number of keys to choose the point.

In a second step, we need to identify the point on the Geographic axes: 

In this step, we need to create the geographic axes to identify the X coordinator and Y coordinator, or we can say that latitude and longitude coordinator by using four-point. In this step, we can use the hold command and geo limits function to maintain the map.

After the selection of point and coordinator, now let’s see the input argument and output argument as follows.

Input Argument:

Input argument means the point that we pass with the ginput () function. Here we use num to denote the input argument. Num means a number of points that we need to identify, and it is a positive number.

Output Argument:

Output argument means the actual result; when we execute the ginput () function with some specified value, then we get some new values such as the first component. By using the first component that uses the X coordinator, we can identify the coordinators, and that returns the scalar or vector column. In which we assume some coordinator and conditions as follows.

  1. All values are present in the X coordinator for the Cartesian axes.
  2. When we consider the polar axes, all values are in theta angles.
  3. When we consider the geographic axes, then all values are in latitudes, in which if the value is positive, then it corresponds to the north direction, and if the value is negative, then latitude corresponds to the south direction.
  4. If we select the coordinator outside the axes, then the assumption of values is

For second component that Y coordinator is as follows:

In the second component, we also the coordinator, and it returns the scalar to the vector column for the following conditions.

  1. All values are present in the Y coordinator for the Cartesian axes.
  2. When we consider the polar axes, all values are in the radius.
  3. When we consider the geographic axes, then all values are in longitudes, in which if the value is positive, then it corresponds to the east direction, and if the value is negative, then latitude corresponds to the east direction.
  4. If we select the coordinator outside the axes, then the assumption of values is different, that is, value relative to the axes origin.

Identify the points by using the Keys and Mouse button:

In this method, we can identify the point by using the mouse and keyboard. For the mouse, we have a different assumption that is 1 for the left side button, 2 for the middle button, and 3 for the right-side button. When we press double click, then it also indicates the two values. On the other hand, the keyboard indicates the corresponding numbers.

Examples

Now let’s see the different examples of ginput () function for better understanding as follows.

Let’s see the very simple and basic example of the ginput () function as follows.

[x,y] = ginput(3)

Explanation

This is a very simple example; here, we specify the X and Y coordinator with ginput value is 3, as shown in the above statement. After execution of this ginput () function, we need to select a point by using a mouse or keyboard. The final result of the above statement we illustrated by using the screenshot is as follows.

Matlab ginput output 1

The above screenshot shows the graph, and the below screenshot shows the point that we selected by using the mouse.

Matlab ginput output 2

After that, execute the below command then we will get the graph as shown in the below screenshot.

plot(x,y);

Matlab ginput output 3

So in this way, we can use the ginput () function as per our requirement for different purposes.

Recommended Articles

This is a guide to Matlab ginput. Here we discuss the basic syntax of input, and we also see different examples of input. You may also have a look at the following articles to learn more –

  1. Matlab Mod
  2. Matlab Backslash
  3. Impulse Response Matlab
  4. Matlab limit

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