Barak Shenhav Early Evolution Course 11 Feb 2001 MATLAB Visualization, Functions & Debugging.

Slides:



Advertisements
Similar presentations
CSE 123 Plots in MATLAB. Easiest way to plot Syntax: ezplot(fun) ezplot(fun,[min,max]) ezplot(fun2) ezplot(fun2,[xmin,xmax,ymin,ymax]) ezplot(fun) plots.
Advertisements

Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
DAY 8: MICROSOFT EXCEL – CHAPTER 5 Aliya Farheen February 5, 2015.
Introduction to M ATLAB 2 Graphics Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MATLAB GRAPHICS 2-D.
Graphics in MATLAB Week 15 – 5/5/09 Kate Musgrave
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
Introduction to M ATLAB Basic Graphics
Plotting - Advanced. FPLOT Plots a function f(x) written as a string within quotation marks. The free variable needs to be designated with x. The lower.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication ENGINEERING SERIES.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
CMPS 1371 Introduction to Computing for Engineers PLOTTING.
1 "A picture is worth a thousand words." Graphical representation is useful for: Error detection - you can locate outliers in a dataset, program bugs,
MATLAB Plotting With MATLAB 1. Two Dimensional Plots The xy plot is the most commonly used plot by engineers The independent variable is usually called.
Matlab tutorial course Lesson 5: Loading and writing data, producing visual output
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
INTRODUCTION TO MATLAB LAB# 01
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
MATLAB for Engineers, by Holly Moore. ISBN © 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is.
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication Linda Driskill, Gang Cheng,
SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 9”
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
DAY 6: MICROSOFT EXCEL – CHAPTER 3 Sravanthi Lakkimsetty September 2, 2015.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
Recap Plots with More than one Line Plots of Complex Arrays Line, Color and Mark Style Axis Scaling and Annotating Plots Subplots Polar Plots Logarithmic.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Sept. 26, 2005 Lecture 6 - By Paul Lin 1 CPET 190 Lecture 6 Problem Solving with MATLAB
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
Figures & Axes, Printing & Saving. Outline Announcements –Homework I on web, due Wed. 5PM by –No lecture on Fri. 10/26, rescheduled to Wed. 10/31.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
An Introduction to Programming in Matlab Emily Blumenthal
EEE 242 Computer Tools for Electrical Engineering
Figures & Axes, Printing & Saving. Outline Announcements –Homework I on web, due Wed. 5PM by e- mail A word on HWI and cookies What happens when you plot.
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
Lecture 17 More Plotting Chapter 12 Matrices. Outline from Chapter D Plotting 11.4 Surface Plots 11.5 Interacting with Plotted Data.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Session III Plotting in MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU MATLAB Tutorials.
Plotting ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Plotting Chapter 5.
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Ch3 Graphics Overview of Plotting Editing Plots
Lecture 25: Exploring data
MatLab – Palm Chapter 5 2-D & 3-D Plots
Net 222: Communications and networks fundamentals (Practical Part)
Lecture 10 2D plotting & curve fitting
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
Today’s Lecture Matlab Graphics
MatLab – 2D Plots 2 MATLAB has many built-in functions and commands to create various types of plots. Instructor notes: We start with an example of some.
Tutorial 2 SEG7550 Introduction to MATLAB II
MATLAB How to use (using M-files)
Advanced Plotting Techniques
Introduction to MATLAB Plotting LAB 3
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Yang-Ming University, Taipei, Taiwan
Plotting Signals in MATLAB
Designing Effective Graphics Using MATLAB
Presentation transcript:

Barak Shenhav Early Evolution Course 11 Feb 2001 MATLAB Visualization, Functions & Debugging

Visualization

Getting Started

Creating a Plot x = 0:pi/100:2*pi; y = sin(x); plot(x, y)

Multiple Data Sets y2 = sin(x -.25); y3 = sin(x -.5); plot(x, y, x, y2, x, y3) legend('sin(x)', 'sin(x -.25)', 'sin(x -.5)')

Line Styles, Colors and Markers plot(x, y, 'r:+') x1 = 0:pi/100:2*pi; x2 = 0:pi/10:2*pi; plot(x1, sin(x1), 'r:', x2, sin(x2), 'r+')

Multiple Plots plot(x, y, 'r') figure plot(x, y, 'b') figure(1) plot(x, y, 'g') close all subplot(2, 2, 1); plot(x, y, 'r') subplot(2, 2, 2); plot(x, y, 'b') subplot(2, 2, 3); plot(x, y, 'g') subplot(2, 2, 4); plot(x, y, 'y')

Axes Control plot(x, y, x, y2, x, y3) axis([0 2*pi –1 1]) grid on axis auto axis off axis on axis equal axis square

Other Plots plot - Graph 2-D data with linear scales for both axes plot3 - Graph 3-D data with linear scales for both axes loglog - Graph with logarithmic scales for both axes semilogx - Graph with a logarithmic scale for the x- axis and a linear scale for the y-axis semilogy - Graph with a logarithmic scale for the y- axis and a linear scale for the x-axis plotyy - Graph with y-tick labels on the left and right side

3-D Plot t = 0:pi/50:10*pi; plot3(sin(t), cos(t), t) grid on axis square

Labels and Titles x = -pi:pi/100:pi; y = sin(x); plot(x,y) axis([-pi pi -1 1]) ylabel('sin(x)') xlabel('-\pi \leq {\itx} \leq \pi') title('\fontsize{16}Graph of the sine function') text(1,-1/3,'\bf{Note the odd symmetry.}')

Get Properties Finding handles: gcf - get current figure handle gca - get current axes handle Getting properties : get(h) - all properties of the graphics object identified by the handle h. get(h, 'PName') - get the value of the property ‘PName' of the graphics object identified by h.

Set Properties Setting properties : set(h, ’PName', PValue,...) - sets the named properties to the specified values on the object(s) identified by the handle(s). For example : x = -pi:.1:pi; y = sin(x); plot(x, y) set(gca, 'XTick', -pi:pi/2:pi) set(gca, 'XTickLabel', {'-pi','-pi/2','0','pi/2','pi'})

Bar Charts y = round(rand(5,3)*10); subplot(2, 2, 1) bar(Y, 'group') title 'Group' subplot(2, 2, 2) bar(Y, 'stack') title 'Stack' subplot(2, 2, 3) barh(Y, 'stack') title 'Stack' subplot(2, 2, 4) bar(Y,1.5) title 'Width = 1.5'

Pie Chart val = [ ]; explode = [0 0 1]; h = pie(val, explode); colormap summer textObjs = findobj(h, 'Type', 'text'); newStr = {'X'; 'Y'; 'Z'}; set(textObjs, {'String'}, newStr)

Histogram Y = randn(10000,3); hist(Y)

Contour and Quiver n = -2.0:.2:2.0; [X,Y,Z] = peaks(n); [C, h] = contour(X,Y,Z,10); Colormap('default'); clabel(C,h) [U,V] = gradient(Z,.2); hold on quiver(X,Y,U,V) hold off

Mesh [U, V] = meshgrid(-8:.5:8); R = sqrt(U.^2 + V.^2) + eps; H = sin(R)./R; mesh(H)

Surf surf(X, Y, Z, 'FaceColor', 'interp', … 'EdgeColor', 'none', … 'FaceLighting', 'phong') axis tight view(-50,30) camlight left

Movies Z = peaks; surf(Z); axis tight set(gca, 'nextplot', 'replacechildren'); % Record the movie for j = 1:20 surf(sin(2*pi*j/20)*Z, Z) M(j) = getframe; end % Play the movie twenty times movie(M,20)

Saving Figures From menu: File  Save – MATLAB format File  Export – Other graphics formats From command line: Saveas(gcf, filename, extension) Print

The Importance of Being Lognormal  cLognormal Normal

Where Did Life Start ? Life Started Here Q=N/N G

time Compositional Carpet

Functions function r = rank(A,tol) % RANK Matrix rank. % RANK(A) provides an estimate of the number of % linearly independent rows or columns of a % matrix A. % RANK(A,tol) is the number of singular values of % A that are larger than tol. % By default tol = max(size(A)) * norm(A) * eps. s = svd(A); if nargin==1 tol = max(size(A)) * max(s) * eps; end r = sum(s > tol);

MATLAB Components

MATLAB Editor

Editor Toolbar Step in/over Breakpoint Evaluation Quit The function call stack

Strings s1 = 'Hello world 1' s2 = ['Hello ' 'world' ' 2'] s3 = ['Hello world ' num2str(3)] s4 = sprintf('Hello world %d', 4) s5 = ['Hello' ; 'world' ; 'in' ; 'lines'] % ERROR s5 = char({'Hello' ; 'world' ; 'in' ; 'lines'}) % OK

Symbolic Math Toolbox-Funtool

N G =100 N=30 Percent Compositional Error Catastrophe (0.4,0.5) (0.5,0.6) (0.6,0.7) (0.9,1) (0.8,0.9) (0.7,0.8) Range of  values

** S Q = N NGNG Optimal Assembly Size N ~ 3.5N G