🌐
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › line plots
plot - 2-D line plot - MATLAB
Example: plot(tbl,"x",vartype("numeric")) specifies all numeric variables for the y-coordinates. Target axes, specified as an Axes object, a PolarAxes object, or a GeographicAxes object. If you do not specify the axes, MATLAB plots into the current axes or it creates an Axes object if one does ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 243993-creating-a-matlab-plot-with-a-varying-variables
Creating a MATLAB Plot with a varying variables? - MATLAB Answers - MATLAB Central
September 20, 2015 - I essentially have to use Matlab to plot the function f(x) = x^m for m = 1,2,3, and 4 on the same figure, as x runs from 1 to 2. ... However, when I execute the script, it returns the error "Matrix dimensions must match". Anyone know an alternative route? Sign in to comment.
🌐
TutorialsPoint
tutorialspoint.com › matlab › matlab_plotting.htm
MATLAB - Plotting
x = [-10 : 0.01: 10]; y = 3*x.^4 + 2 * x.^3 + 7 * x.^2 + 2 * x + 9; g = 5 * x.^3 + 9 * x + 2; plot(x, y, 'r', x, g, 'g') When you run the file, MATLAB generates the following graph − · The axis command allows you to set the axis scales. You can provide minimum and maximum values for x and y axes using the axis command in the following way −
🌐
MathWorks
mathworks.com › matlabcentral › answers › 179364-how-do-i-plot-a-function-of-one-variable-easily-in-matlab
How do I plot a function of one variable easily in matlab? - MATLAB Answers - MATLAB Central
February 19, 2015 - The third argument to linspace is the length of the vector it produces. (The default is 100.) ... https://www.mathworks.com/matlabcentral/answers/179364-how-do-i-plot-a-function-of-one-variable-easily-in-matlab#comment_267317
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-plot-a-function-of-two-variables-in-matlab
How To Plot a Function of Two Variables in MATLAB? | GeeksforGeeks
April 28, 2025 - Method 1: Creating a histogram of two variables with base R In this approach to create a histogram pf two variables, the user needs to call the hist() function twice as there is two number of v ... MATLAB functions are generally defined input ...
🌐
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › data distribution plots
Plots That Support Tables - MATLAB & Simulink
Create a table containing three variables. Then pass the table as the first argument to the plot function followed by the names of the variables you want to plot. In this case, plot the Input variable on the x-axis and the Output1 variable on the y-axis.
🌐
MathWorks
mathworks.com › matlab › get started with matlab
2-D and 3-D Plots - MATLAB & Simulink
To add plots to an existing figure, use hold on. Until you use hold off or close the window, all plots appear in the current figure window. x = linspace(0,2*pi); y = sin(x); plot(x,y) hold on y2 = cos(x); plot(x,y2,":") legend("sin","cos") hold off · Three-dimensional plots typically display a surface defined by a function in two variables,
Find elsewhere
🌐
MathWorks
mathworks.com › matlabcentral › answers › 34098-select-variables-for-plot
Select variables for plot - MATLAB Answers - MATLAB Central
March 31, 2012 - I didn't have MATLAB open so the code may gve errors! Sorry about that. But the idea should be pretty clear. ... I like your way, I'll try that the next time. Sign in to comment. ... Now as 'N' is not 0, the statement is always true. ... Thx, i really figured out how to do it yesterday, just like you said. About the pl(1:2)='t1,y1(:,1)', I found the right way to do it, it was ... So when i get all the columns selected for ply, I simply use plot(plt,ply).
Top answer
1 of 1
9
People seem not to recognize this. Not sure why, but it seems a common misperception. A level set is the set of all points where the function z(x1,x2) is constant, at some given value. In this case, that value is z(x1,x2)==1. So you want to do a contour plot! The obvious solution is to try ezcontour. But if you did, you will be disapponted. Why? Because ezcontour does not allow you to specify the contour level of interest. Here, that is z(x1,x2) = 1. (Actually, it looks like ezcontour is now being deprecated, to be replaced eventually by fcontour. Sadly, they still have not obviously given us the ability to plot only ONE desired contour line with fcontour. IMHO, that would be a mistake. HAPPILY, they did give us that capability! It is just not documented as well as I would have liked.) Instead, the classic solution in MATLAB is to use contour. Contour works on an array of values. So in the classical solution, you would first use meshgrid to generate a grid over x1 and x2. Then evaluate the function at each grid point in the arrays of x1 and x2, representing points in the (x1,x2) plane. Only then call contour, telling it to use a SPECIFIC contour level, here z==1. So, lets instead try using a simpler solution in MATLAB, thus fcontour. Create a function of two variables. Simplest is to learn about function handles. Don't forget to use the correct operators, that will allow vectorized operations between arrays of x1 and x2. Here that means you need to use the .^ and .* operators. zfun = @(x1,x2) x1.^2 + x2.^2 - x1.*x2; zhandle = fcontour(zfun) zhandle = FunctionContour with properties: Function: @(x1,x2)x1.^2+x2.^2-x1.*x2 LineColor: 'flat' LineStyle: '-' LineWidth: 0.5000 Fill: 'off' LevelList: [10 20 30 40 50 60 70] Show all properties So I did a contour plot. So what? Where is the contour that indicates where z(x1,x2)==1? Look carefully at the properties we see there. We find LevelList! Will that help? zhandle.LevelList = 1; xlabel x1 ylabel x2 title(func2str(zfun)) grid on zhandle.YRange = [-2,2]; zhandle.XRange = [-2,2]; axis equal That looks reasonable now. Anyway, not difficult. It took a few lines of code to make the picture as pretty as I might like, but then I tend to be a perfectionist. It does get into some of the newer toys to be found in MATLAB, which is why I answered this question in some depth.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 314125-how-to-plot-two-variables-in-a-single-function
How to plot two variables in a single function? - MATLAB Answers - MATLAB Central
November 27, 2016 - How do I create a plot that shows the variation of k with respect to x in the following function without actually rearranging it? y-a*x + sin(b*x^2) + k*m=0 Assume the remaining terms have fixe...
🌐
Engineering LibreTexts
eng.libretexts.org › bookshelves › computer science › applied programming › a brief introduction to engineering computation with matlab (beyenir) › 1: chapters
1.3: Plotting in MATLAB - Engineering LibreTexts
July 31, 2021 - ... Probably the most common method for creating a plot is by issuing plot(x, y) statement where function y is plotted against x. Type in the following statement at the MATLAB prompt: ... Having variables assigned in the Workspace, x and y=sin(x) ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 357211-how-to-plot-variables-inside-an-equation
How to plot variables inside an equation? - MATLAB Answers - MATLAB Central
September 18, 2017 - I have defined Vb Vcr and Kb as symbolic variables so as this: syms Vb Vc; Kb=sym(Vb/Vcr). What I finally want to obtain is a graphic with Pb in the y axis and Vb/Vcr (Kb) in the x axis as shown in the previuos image. How can I do this? I add the code in my command window: Thanks a lot!!! ... https://www.mathworks.com/matlabcentral/answers/357211-how-to-plot-variables-inside-an-equation#comment_485373
🌐
MathWorks
mathworks.com › matlabcentral › answers › 373274-how-to-draw-plot-with-just-one-variable
How to draw plot with just one variable - MATLAB Answers - MATLAB Central
December 16, 2017 - https://www.mathworks.com/matlabcentral/answers/373274-how-to-draw-plot-with-just-one-variable#answer_296543 ... I am not certain what you want to do. ... It interpolates ‘y’ to the size of ‘myothervariable’, then plots it.
🌐
MathWorks
mathworks.com › matlab
Plotting Data - MATLAB & Simulink
load | plot | legend | xlabel | ylabel | title | size ... Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands. ... Choose a web site to get translated content where available and see local events and offers.
🌐
MathWorks
mathworks.com › symbolic math toolbox › graphics
Create Plots of Symbolic Expressions - MATLAB & Simulink
Show the underlying structure in the points by superimposing a plot of the sine function. First, use hold on to retain the scatter plot. Then, use fplot to plot the sine function. ... Combine symbolic and numeric plots in 3-D by using MATLAB and Symbolic Math Toolbox plotting functions.
🌐
MathWorks
mathworks.com › videos › create-plots-from-your-data-quickly-and-interactively-in-matlab-1616063232625.html
Plot Your Data in MATLAB – Without Writing Code - MATLAB
Select some variables first, then try selecting different chart types. • Explore different data in the same visualization format. Select the chart type first. The task will prompt you for data. • Customize the appearance of your plot. For example, you can change the marker symbol for line ...
Published   March 18, 2021