Matrix Manipulation and 2D Plotting

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
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.
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to Matlab
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
Introduction to MATLAB
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
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.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Excel 2007 Graphs & Charts. TYPES OF CHARTS Column Bar Pie Line.
1.3 ARRAYS, FILES, AND PLOTS + FOURIER SERIES BY MR. Q.
MATLAB - Basics Centro de Informática Universidade Federal de Pernambuco Aprendizagem de Máquina – IN1102 Arley Ristar –
Loading Excel Double click the Excel icon on the desktop (if you have this) OR Click on Start All Programs Microsoft Office Microsoft Office Excel 2003.
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.
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
MATLAB GRAPHICS 2-D.
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
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.
EGR106 Week 4 Two Dimensional Plots Multiple Plots Plot Formatting Homework.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
MATLAB Fundamentals.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Graphing Behavioral Data for FBA/BIP Special Services Baldwin County Public Schools.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
INTRODUCTION TO MATLAB LAB# 01
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
Lesson 11-1 Matrix Basics and Augmented Matrices Objective: To learn to solve systems of linear equation using matrices.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D.
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
10.3 Systems of Linear Equations: Matrices. A matrix is defined as a rectangular array of numbers, Column 1Column 2 Column jColumn n Row 1 Row 2 Row 3.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
1-d Arrays & Plotting.
Introduction To Matlab Class 4 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD Double click the matlab icon When prompted click “Skip”
MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
An Introduction to Programming in Matlab Emily Blumenthal
Beginning Programming for Engineers Animation. Special matrix functions >> clear >> ones(2,3) >> zeros(3,5) >> ones(2) >> zeros(3) >> eye(4) >> magic(4)
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.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Prof. N. P. Jadhav Presented by. Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation.
ECE 1304 Introduction to Electrical and Computer Engineering
Lecture 25: Exploring data
Matrices and Arrays.
MATLAB How to use (using M-files) Double click this icon
MATH 493 Introduction to MATLAB
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files)
Plotting Signals in MATLAB
Presentation transcript:

Matrix Manipulation and 2D Plotting

Review Command Line Semi Colon to suppress output Entering a Matrix Square brackets X = [1,2,3,4,5] Generate arrays (1D matrices) X = Start:Step:End X = 1:3:13

Matrix Manipulation The basic unit of data storage Extract a part of a matrix use round brackets third entry in a 1D matrix X(3) last Entry X(end) fourth to ninth entries X(4:9) A 2D matrix Entry at the third row, second column A(3,2) All of the third row A(3,:)

Examples Create a 5 by 5 magic square There is a inbuilt function Extract the value at the third row, fourth column Extract the last value of the third column Extract all of the fifth row Replace the value at row 2, column 4 with 100 Replace all of the first column with zeros Delete all of the fourth row A = magic(5) A(3,4) A(end,3) A(5,:) A(2,4)=100 A(:,1)=0 A(4,:)=[]

Questions What do the following command do? A' B = [A';A'] A(:) If A is a 2D matrix A' B = [A';A'] A(:)

Solving linear Systems Represent in matrix form Use backslash operator Inv(A)*b A/b

Solve

2D Plotting Various, flexible, plotting routines. The basic command is plot(x,y) This plots the vector of x coordinates against the vector of y coordinates X and y must be the same size plot(y) Plots the vector y against its indices

Plotting Plot the function y = sin(x) +x -2 for x = [-2,9] plot(x,y)

Plot the following y = 0.2* e-0.1x y = sin(x) +x^2 -2 for x = [-1,1]

Data Loading Navigate to appropriate directory Right click on file and select importdata If in plain text format A = Load(‘file name.???’); If a other formats (eg. Excel files) A = importdata(‘file name.xls’);

Data Loading Tasks Download and then load data file https://files.warwick.ac.uk/kimmckelvey/files/CVBulk.tsv Load CVBulk.tsv data Create a plot of this data

>> data = load('c:/CVBulk.tsv'); >> figure >> plot(data(:,1),data(:,2),'r') >> title('CV') >> xlabel('Voltage / V') >> ylabel('Current / A')

Changing Attributes Basic usage: plot(x, y, ’Attributes’) To plot a green dashed line plot(x, y, ’g--’) To plot yellow circle at the data points plot(x, y, ‘yo’)

Titles etc Adding a title Axes labels Legend Title(‘whoop whoop’) xlabel(‘Peanuts’) ylabel(‘Vanilla’) Legend legend('222','33')

Multiple To plot multiple line of the same plot plot(X,Y,'y-',X1,Y1,'go') Or use the ‘hold on’ function plot(x, y, ’b.’) hold on plot(v, u, ‘r’)

Subplot Used to plot multiple graphs in the same frame Try: Plot sine and cosine between 0 and 10 on two separate axes in the same frame >> subplot(2,1,1) >> plot(x, y) >> subplot(2,1,2) >> plot(u, v)

More attributes: Plots are fully editable from the figure window. Once you have a plot, you can click Tools->Edit plot to edit anything. plot(X1,Y1,LineSpec,'PropertyName',PropertyValue) Plot(x, y, ’r’, ‘LineWidth’, 3, ‘MarkerSize',10) But all this can also be done from the command line set(gca,'XTick',-pi:pi/2:pi)

More types of plots Histograms Bar Pie Charts Create a bar plot of the CVBulk data

Task Plot the following equations on the same graph (different colours) Solve the system of equations Plot the solution on the same graph Add appropriate titles, labels and legend