How To Plot A Scatter Plot In Matlab | Matlab Tutorial – 59 – Basic Scatter Plots

Math And Science

Subscribe Here





Matlab Tutorial - 59 - Basic Scatter Plots


Hello, and welcome to the section of the Matlab Tutor we’re going to begin to talk about basic graphing in Matlab basic plotting of data and a lot of times. That’s what Matlab is really so powerful with is because it can do so many really cool and detailed calculations with raw data and a lot of times you want to present that data to other people, so you’ll be generating a plot or some kind of a graph, so the easiest most straightforward most, you know, fundamental way to plot and present data in MATLAB is to is to have raw data coming in. Usually, you know, you’ll do an experiment. You’ll be collecting data. You’ll do calculations with it, and then you’ll want to present it so the easiest way to do that is to just bring in that raw data, So let’s say, for instance. I’m gonna plot X versus Y XY scatter plot. So I’ve literally got a file or I’ve got a bunch of data that I’ve collected and in terms of XY points so this isn’t really a function so to speak, It’s just more of just XY data, right, so let’s say that data is 0 1 2 3 4 5 6 7 OK, and that is my X data, so it’s going up from 0 to 7 so I’m going to go and hit enter, and that’s creating a basically a vector, a single line matrix of 0 to 7 now. I’m going to define a Y vector. That’s going to be something like 1 2 3 4 3 We go down here 3 2 1 0 so let me see how many points. I have 1 2 3 4 5 6 7 8 So that matches the number of points in my other guy. So if I hit enter here, my Y data. Is this so this is something? I’ve collected right and X is equal to 0 Y is equal to 1 at X is equal to 1 Y is equal to 2 and so on, so I’ve got XY pairs of data. All of the X data is contained in a vector X. All the Y data is contained in a vector. Y ok, this could represent some function. Your your calculated or something you’ve measured or whatever if you want to plot X versus Y right. And in terms of an XY plot, you use the plot function, which is built in the Matlab X comma Y. So when you pass the plot function something, it’s going to expect some x-values, and then it’s going to expect some y-value so in this case, it’s raw data, so let’s see what happens we hit, enter and up pops a window, and if you think about it, this makes sense because the values of Y we’re increasing. And then when they got you, see what happened over here when they got it to this maximum before they started decreasing again. So this is the plot window. Whenever you use the plot command. The plot is going to pop up in a new window. Here, it’s pretty. Spartan, it’s pretty plain, but the good news with Matlab is that you can really customize. You can customize all this stuff. You can change the way the axes look. You can change the way. The line looks. You can change a lot of stuff about it. Let me go ahead and show you a couple of quick things that you’ll probably want to do right away. You might want to add a title to your plot, so you can use the title command and literally open it up and just type in a title. My favorite plot close it off with a single quote hit enter, and then you go back to that plot window That’s still active and the title has popped up with my favorite plot. All right, you’re probably going to want to. Do you probably want going to want to label the x-axi’s? So I’m going to call this x-axi’s and as soon as I hit enter, I’ll pull up the MATLAB window and you can see. The X-axi’s text has appeared just below the x-axi’s so the Y label. I’m gonna call that the y-axis. This could be anything I want. I mean, that could be. I could be measuring bumblebees or something. And the y-axis would be labeled bumble bee population or something, but for right now. I’m going to do X-axis and Y-axis. And when I do that on the command line of Matlab, it’s basically sending those plot commands to the active plot window that I’ve kind of generated here, so this is starting to look a little bit like a plot, so I’ve got data here. I’m plotting XY functions or XY data Now before I forget, I want to go and make sure and let you know you can definitely set the title and set the X Axis and the Y Axis in terms of MATLAB commands. But if you notice there’s a menu up here on top of the plot window, and if you go to insert, you have the ability to change the X label, the while label and the title right inside this window, so you don’t have to actually use commands to do that, you can just go in here and select title and it’s going to let you highlight this, and then you can go over here and say my favorite Martian or whatever you want to do, and that’s a title. You can go insert Y-axis, and maybe I could go. Maybe I can say, okay. This is really population of Martians like this, and when you do that, it goes and sets it vertically. All right, so you can set the X and y labels and you can set the title from the built in menu here and it’s plotting the data. Now notice there’s a couple of features in here that I’ve touched on before, but Ill. Just make sure you understand. There’s a zoom feature here, so you can go here and you can draw a box once you have that, and it’s going to zoom into this. You could zoom in again and you can really look and see how your data’s behaving when you hit the minus magnifying glass, you can go back to your standard guy, so you can zoom around and play around with the plot. Now you can also use this one. Which is the data cursor? It’s basically a trace. So notice when I change to a crosshair. I can click down here and it’s gonna snap to. The nearest data. Point at X is equal to 1 Y is equal to 2 You know, I can go over here and click and do a notice that X is equal to 2 Y is equal to 3 and I can go Click up here and see the XY values wherever I click now. The neat thing is much like a graphing calculator once Ive. Got this thing snapped onto my graph. I can. I can actually use the left and right arrow keys. That’s what I’m doing now. I’m just hitting the left and right arrow keys to cycle through these points. So you know, a very, very simple example, but I just want to make sure you understand. The easiest way to put a plot together in Matlab is to define the X data, define the Y data and then just do a general scatter plot, which is using the plot command. You’re plotting X versus Y You can set the titles of the graph and the X and y axe’s labels from the command line here. You can also set them from inside here, and you can also zoom in and out of your plots, and you can also trace your plots much like a graphing calculator, so it actually has some really cool features. Another thing you can do is you can go and let me go back here and you can do copy figure from the. Edit menu. You can do copy Figg. And then you can go into a word processor or any other document and paste that figure directly in so any time you generate graphics in MATLAB, not only. Can you manipulate them with a MATLAB? But you can take them and pull them into other reports and documentation that you might be writing as part of your project.

0.3.0 | Wor Build 0.3.0 Installation Guide

Transcript: [MUSIC] Okay, so in this video? I want to take a look at the new windows on Raspberry Pi build 0.3.0 and this is the latest version. It's just been released today and this version you have to build by yourself. You have to get your own whim, and then you...

read more