NoViC, Dept. of Mechanical Eng. 2016. 03. 17. Acoustics Lab., NoViC 1. Download Matlab 2.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Introduction to MATLAB ES 156 Signals and Systems 2008 Harvard SEAS.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to MATLAB ES 156 Signals and Systems 2007 Harvard SEAS Prepared by Jiajun Gu.
Matlab intro The Environment
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
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.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Tutorial 1SEG7550 Introduction to MATLAB 18 th, SEP
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
How to Use MATLAB A Brief Introduction. 2 What can MATLAB do? Matrix Operations Symbolic Computations Simulations Programming 2D/3D Visualization.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
COMP 116: Introduction to Scientific Programming Lecture 6: Scripts and publishing, Creating matrices.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Josh Xiaomin Xi PhD Candidate Feb 27, 2013 A tutorial from.
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read.
Introduction to MATLAB
Octave. Getting Started Arithmetic is as usual: – What would (a-V)(V-1)V be for a=0.1 and V=-56? – Multiplication is *, division is /
OUTLINE Overview Numbers, variables and similar in Matlab
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
MATLAB Tutorial EE313 Signals and Systems Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Jeff Andrews.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to Matlab
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
MT411 Robotic Engineering Asian Institution of Technology (AIT) Chapter 1 Introduction to Matrix Narong Aphiratsakun, D.Eng.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
Part(2) MATLAB.
Introduction to MATLAB
Introduction to MATLAB
Numeric, Cell and Structural Arrays One of the strenghts of MATLAB is the capabilty to handle collection of numbers called ARRAYS. MATLAB refers to scalars,
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
TexPoint fonts used in EMF.
Introduction to MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
INTRODUCTION TO MATLAB AM2032 JAYANTA MUKHERJEE.
MATH 493 Introduction to MATLAB
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Introduction to MATLAB [Vectors and Matrices] Lab 2
INTRODUCTION TO MATLAB
Announcements P3 due today
How to Use MATLAB A Brief Introduction.
Presentation transcript:

NoViC, Dept. of Mechanical Eng

Acoustics Lab., NoViC 1. Download Matlab 2

Acoustics Lab., NoViC Activation Key Create “Mathworks” account 3

Acoustics Lab., NoViC 3. Installation 4 Matlab default view

Acoustics Lab., NoViC 1. Input variables and operations (1/5) 5 >> a = 1 a = 1 >> b = 2 b = 2 Command Window >> a + b ans = 3 >> a - b ans = >> a * b ans = 2 >> a / b ans =  4 fundamental arithmetic operations  Scalar input (real value) Command Window + : Addition - : Subtraction * : Multiplication / : Division  Priority of operation: (*, /) > (+, -) >> a + b / a - b ans = 1 >> (a + b) / (a - b) ans = -3 Command Window  Square operation (^) >> a^5 (when a=2) ans = 32 >> a^5+1 ans = 33 >> a^(5+1) ans = 64 Command Window

Acoustics Lab., NoViC 1. Input variables and operations (2/5) 6 >> c = a+j*b c = i >> c = a+i*b c = i Command Window  Scalar input (complex value) i or j : complex variable  Trigonometric functions >>x = 45/180*pi x = >> sin(x) ans = >> cos(x) ans = Command Window  Complex operations >> real(c) ans = 1 >> imag(c) ans = 2 >> conj(c) ans = i >> abs(c) ans = >> angle(c) ans = Command Window real(c): real value of c imag(c): image value of c conj(c): complex conjugate of c abs(c): absolute value of c angle(c): phase value of c >> tan(x) ans = >> exp(j*x) ans = i Real Im  1-2i 1 2

Acoustics Lab., NoViC 1. Input variables and operations (3/5) 7 >> A=[1 2; 3 4] A = >> B=[3 5; 7 9] B = >> C = [1; 5] Command Window  Matrix and vector input  Matrix-matrix operation >> A + B ans = >> A - B ans = Command Window >> C = [1 5]' C = 1 5 >> D = [2 3] D = 2 3 >> E = [1:2:9] E = ; (semicolon): Changing the row : (colon): Pick out selected row ‘ (inverted comma): Transpose operator >> A * B ans = >> A^3 ans = >> A*C ans = 1 5 >> D*A ans = Command Window  Matrix-vector/scalar operation >> A*5 ans = >> A/2 ans =

Acoustics Lab., NoViC 1. Input variables and operations (4/5) 8 Command Window  Other matrix operations >> transpose(A) ans = >> det(A) ans = -2 >> inv(A) ans = >> A * inv(A) ans = >> [V,D] = eig(A) V = D = Command Window >> size(A) ans = 2 2 >> size(C) ans = 2 1 >> length(A) ans = 2 >> length(C) ans = 2 >> eye(2,2) ans = >> zeros(1,2) ans = 0 0 >> ones(1,2) ans = 1 1 transpose(A)  same with ‘ (inverted comma) det(A)  Determinant of A matrix inv(A)  Inverse matrix of A matrix eig(A)  Eigenvalues and vectors V: Eigenvectors D: Eigenvalues size(A)  Size of A matrix length(A)  length of A matrix eye(m,n)  Make the mXn identity matrix zeros(m,n)  Make the mXn matrix of zeros ones(m,n)  Make the mXn matrix of ones

Acoustics Lab., NoViC 1. Input variables and operations (5/5) 9 Command Window  Comma for matrix computation >> A*B ans = >> A.*B ans = >> A^2 ans = >> A.^2 ans = Command Window >> x=[0:0.1:pi]; >> y=sin(x); ; (semicolon): hide the input/output variables variables save in the workspace  Function and vector General matrix multi. Element by element multi. General matrix multi. Element by element multi. Final value (Upper bound) Initial value (Lower bound) Step size X=[ … ] (Dimension: 1X32) Y=[ ] (Dimension: 1X32)

Acoustics Lab., NoViC 2. Plotting the graph (1/1) 10  Setting the variables (input and output values)  Plotting the figure >> figure(1) >> plot(x, y, 'r-') >> grid on >> xlabel('x [rad]') >> ylabel('sin(x)') >> title('sin function') Command Window >> x=[0:0.1:pi]; >> y=sin(x); figure(1)  numbering the figure Plot(x,y,’r-’)  x: x-axis data, y: y-axis data, ‘r-’: red solid line grid on  show the grid line on the figure To get the more information of plot, Input the help plot in command window Command Window >> help plot semilogx  x-axis is log scale semilogy  y-axis is log scale loglog  x, y-axes are log scale

Acoustics Lab., NoViC M-file making 11 F5 Dragging and select several statement +F9 key  Run only in the selected part F9

Acoustics Lab., NoViC 3. Iteration structure (1/2) 12 >> sum = 0; >> for n = 1:10 sum = sum + n; end >> sum sum = 55 Command Window  Example) sum of 1 to 10 for variable = int : n : final statement end Repeat the statement until the final variable Not convenient to use command window Open the editor Click F5 key  save the editor  Implement the MATLAB program

Acoustics Lab., NoViC 3. Iteration structure (2/2) 13  Example) sum of 1 to 10 while conditional statement statement end Repeat the statement until conditional statement is satisfied C.if loop  Example) sum of 1 to 10 if expression1 statement1 elseif expression2 statement2 else statement3 end Implement statement1 if expression1 is satisfied, Implement statement2 if expression1 is unsatisfied and expression2 is unsatisfied, Implement statement3 if expression 1 and 2 are unsatisfied

Acoustics Lab., NoViC 14 function xdot = sdof(t,x) xdot = zeros(2,1); xdot(1) = x(2); xdot(2) = -(2/3)*x(1) - (1/3)*x(2); 1. First-order form t0 = 0; tf = 20; x0 = [0 0.25]; [t, x] = ode45('sdof', [t0 tf], x0); plot(t,x(:,1),'linewidth',3); hold on; plot(t,x(:,2),'--r','linewidth',3); title('Example 1.9.2'); xlabel('Time'); ylabel('Displacement (solide) and velocity (dashed)'); grid on; sdof.m Tutorial_ode45.m where

Acoustics Lab., NoViC Start matlab 2. input this code -> urlwrite(' nt.com/vibrationtoolbox/vtoolbox/ma ster/vtbud.m','vtbud.m'); 3. then input this code -> vtbud 4. Installation will be started You have to select the path where the function files are