The following MATLAB program demonstrate the implementation of the “axis” function with auto option to adjust axis limits of a plot automatically.Įxample % MATLAB program to adjust axes limits automaticallyĪxis auto % Adjusting X-axis and Y-axis limits automatically In MATLAB, we can use the “axis” function with auto option to adjust the X-axis and Y-axis limits automatically depending on the range of the data. In this example, we set the X-axis limits from -6 to 6 and the Y-axis limits from -200 to 200. Next, we call “axis” function to set the X-axis and Y-axis limits simultaneously. After that we call “plot” function to plot the values of “x” and “y”. Then, we calculate cubes of values of “x” and store them in another vector “y”. In the above MATLAB program, we start by calling the “linspace” function to create a vector “x”, having linearly spaced values from -5 to 5. % Set the X axis and Y axis limits simultaneouslyĪxis() % Setting X-axis limits from -6 to 6 and Y-axis limits from -200 to 200 Let us now consider an example program to understand the implementation of axis() function.Įxample % MATLAB program to adjust both axes limits simultaneously In MATLAB, the “axis()” function allows use to adjust both X-axis and Y-axis limits simultaneously. In this example, we set the X-axis limit from 0 to 50 and the Y-axis limit from 0 to 2500. Next, we call functions “xlim” and “ylim” to adjust the X-axis and Y-axis limits respectively. Then, we calculate square of values of “x” and store them in another vector “y”. In this MATLAB program, first of all we call “linspace” function to create a vector “x”, having linearly spaced values from 0 to 50. Ylim() % Setting Y axis limits from 0 to 2500 Xlim() % Setting X axis limits from 0 to 50 Let us consider an example to understand this implementation.Įxample % MATLAB program for adjusting axes limits individually In MATLAB, the “xlim()” and “ylim()” functions are used to adjust the X-axis and Y-axis limits individually. The implementation of these functions in MATLAB programming is demonstrated with the example programs in the below sections of this article. “axis ()” Function - The “axis()” function is used to adjust both X-axis and Y-axis limits simultaneously or automatically. “ylim()” Function - The “ylim()” function is used to adjust Y-axis limit of a plot in MATLAB. “xlim()” Function - The “xlim()” function is used to adjust X-axis limit of a plot in MATLAB. In MATLAB, there are three main functions widely used for adjusting axis limits of a plot. In this tutorial, we will learn about adjusting axis limits of a plot in MATLAB. MATLAB provides various built-in functions, such as xlim(), ylim(), and axis() that help us to adjust axis limits as per our requirements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |