Unit 12 - Unit 12 Visualization in MATLAB Unit Objectives...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Unit 12 Visualization in MATLAB Unit Objectives • Learning to Visualize your results. • Creating 2D plots of your data. • Creating 3D plots of your data. • Formatting and presenting your data. Introduction We now have two languages under our belt. Both have advantages and disadvantages. For example, you would never write a program to operate a car's cruise control in MATLAB. You would use C++ and embed your executable program on a chip inside the car. But if you were designing the car itself, you may use MATLAB. It is easier to use and lots of functions are built in. In this section we are going to learn how to visualize data generated using MATLAB which may further ease the design process. Visualizing solutions graphically makes analyzing your data far easier, and MATLAB includes lots of visualization options. Task 1 - Creating and formatting simple 2D Plots. MATLAB offers a variety of commands to create and customize 2-dimensional plots. Before we go into any detail, let's create a simple plot so you can see MATLAB in action. x = [-5 : 0.05 : 5 ]; y = 2*x.^2.*sin(x.^2); plot(x, y) Now type 'help plot' and review all the different options available for this function. Pay attention to the third and optional string argument that lets you change the color and character plotted. Some of help section may be a little hard to understand, but you should see a lot there you can use right away. Don't get too intimidated that they include information for both beginner and advanced users. Even I don't understand every thing in the help sections the first time I read them. Be sure to follow some of the links in the 'see also' section. Once you have done that, try out the following program, and mess around until you have a pretty good idea how the whole thing works. x = [-5 : 0.05 : 5 ]; y1 = 2*x.^2.*sin(x.^2); y2 = 0.5*x.^3 - 3*x.^2 + 7*x + 32; plot(x, y1, 'ro') %hold on; figure(2); plot(x, y2, 'b-') grid on; xlabel('x-axis description here'); ylabel('y-axis description here'); title('My second graph in MATLAB!'); axis( [ -4 4 -100 100 ] ); text( 1.5, 10, 'Hello World!' ); I don't want to spend too much time talking about the plot function here, since 'help plot' tells you everything you need to know. But there are a couple points of confusion and some features worth mentioning. Remove the 'hold on' command and run the program again. What happened? Now replace the 'hold on' with the command figure(2). What happened? It is important to note that the 'hold' and 'grid' commands toggle the hold state and grid's appearance respectively. To avoid confusion, I prefer to use the more explicit 'hold on','hold off','grid on', and 'grid off' respectively....
View Full Document

This note was uploaded on 10/02/2011 for the course ME 205 taught by Professor Koen during the Spring '07 term at University of Texas.

Page1 / 13

Unit 12 - Unit 12 Visualization in MATLAB Unit Objectives...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online