Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we will start with how to create basic plots in MATLAB. Remember, to create a plot, we need our x and y data in the same length. If I say that x is a vector of points, what do I mean, Student_1?
You mean that x is just a list of values, right?
Exactly! Now, let's say we want to plot x = [1, 2, 3, 4, 5, 6] against y = [3, -1, 2, 4, 5, 1]. Can someone tell me the command we would use?
Is it just plot(x,y)?
That's correct! Make sure to always check that both vectors match in size. Let’s visualize this graph. What do you expect it to look like?
It should be some zigzagging line connecting the points!
Right on! Visualizing the points is a great way to analyze data. We’ll do more of this!
Now that we know how to create a basic plot, let's make our graphs more informative. Why do you think labels and titles are important, Student_4?
So that anyone reading the graph understands what it represents?
That's spot on! In MATLAB, we can add titles and axis labels using xlabel, ylabel, and title. Can anyone give me the syntax?
Like xlabel('x-axis') and title('Graph Title')?
Exactly! Using the backslash for π is also helpful. If I had a sine function plotted, how would I label it?
You'd label the y-axis as 'Sine of x'?
Great! Adding these labels makes the data interpretation easier. Let's add them now!
What if we have more than one dataset? Why might it be useful to display them in a single graph, Student_3?
To compare them directly, right?
Correct! We can plot multiple datasets using the plot function simultaneously. Can someone give me an example syntax?
Like plot(x,y1,'--', x,y2,'-')?
Absolutely! Each dataset can also have a different line style. How do we tell MATLAB which dataset is which?
By adding a legend!
Yes! Using the legend function helps clarify the data presented in the graph, making it much more useful for interpretation.
Plot a point, connect the line, make your graph look just divine!
Imagine you are a painter. Each brushstroke on your canvas connects data points in beautiful harmony.
P.L.E. - Plot, Label, Enhance. This reminds you of the steps: plot your data, label axes, and enhance with titles.
G.P.L.- Graphing, Plotting, Legends - Remember these core concepts for effective plotting!
Term
What function do you use to plot data in MATLAB?
Click to flip
Term
How can you indicate that a dataset is a sine function?
Click to flip
A graphical representation of data points on a coordinate system.
An array of numbers typically representing data points in a specific format.
Text used to describe the x-axis and y-axis of a graph, improving clarity.
Text describing the overall content of a graph.
A key on a graph that explains what different colors or patterns represent.
This section introduces the basics of plotting in MATLAB, including how to create simple graphs and customize their appearance.
In this section, we explore MATLAB's powerful plotting capabilities, detailing how to create 2D plots using vectors, add titles and labels, and manage multiple datasets in a single plot. Understanding these tools enhances the analysis of mathematical functions and data visualization.
In Markdown style, this section emphasizes the importance of plotting within MATLAB for both visualization and understanding of mathematical concepts. It starts with the fundamentals of creating 2D plots using vectors for x and y coordinates. The section explains that the primary command for plotting graphs is plot(x,y), where both x and y must be of the same size, either as row or column vectors. The guide progresses to show how to implement additional features such as axis labels and titles, explaining the syntax used, including how to incorporate the π symbol. Further, it covers how to plot multiple datasets within the same graph and customize the appearance using different line styles and colors. This comprehensive understanding assists students in effectively visualizing their data and mathematical functions.