Lab2 (Signal & System) Instructor: Anan Osothsilp Date: 07 Feb 07.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Programming Methodology (1). Iteration Learning objectives explain the term iteration; repeat a section of code with a for loop; repeat a section of.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Lab5 (Signal & System) Instructor: Anan Osothsilp Date: 20 Feb 07 Due Date 09 March 07.
Functions in MatLab Create a new folder on your Z:drive called MatLab_Class24 Start MatLab and change your current directory to MatLab_Class24 Topics:
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
Matlab tutorial course Exercises 4:. Exercises – for loops Download the scripts loops_example.m and if_else_example.m, run the code Download the function,
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
Lab8 (Signal & System) Instructor: Anan Osothsilp Date: 17 April 07.
Lab1 (Signal & System) Instructor: Anan Osothsilp Date: 30 Jan 07.
General Computer Science for Engineers CISC 106 Lecture 24 Christopher Thorpe Computer and Information Sciences 04/17/2009.
Lab9 (Signal & System) Instructor: Anan Osothsilp Date: 17 April 07.
Copyright 2006 by Pearson Education 1 reading: 4.1 Cumulative sum.
Lab7 (Signal & System) Instructor: Anan Osothsilp Date: 20 Feb 07 Due Date 03 April 07.
Lecture 12 Another loop for repetition The while loop construct © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Lab3 (Signal & System) Instructor: Anan Osothsilp Date: 13 Feb 07.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/30/2009.
1 G:\common\eng1102\1102_200508\02matlab\m10.functions.sxi Today's Agenda ● Introduce Matlab User Functions.
1 Session-13 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-5 due date extended to March 7 Test-1 is on March 9 th ; Demo-5 due date extended to.
CS 1400 Chap 6 Functions. Library routines are functions! root = sqrt (a); power = pow (b, c); function name argument arguments.
LAB-10 1-D Array I Putu Danu Raharja Information & Computer Science Department CCSE - King Fahd University of Petroleum & Minerals.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Computer Programming Lab(5).
Matlab tutorial course Exercises 1:. Exercises Go back to my webpage, download the file ‘startup.m’ and save it in your MATLAB home folder – Must be directly.
Lecture 5 Sorting, Printing, and Summarizing Your Data.
For Loops 2 ENGR 1181 MATLAB 9. For Loops and Looped Programming in Real Life As first introduced last lecture, looping within programs has long been.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
Programming Concept Chapter I Introduction to Java Programming.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
More While Loop Examples CS303E: Elements of Computers and Programming.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Scientific Computing Introduction to Matlab Programming.
 There are times when you will want blocks to repeat. Instead of duplicating blocks and ending up with a long script that might be confusing, there.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 11.
Count and add list of numbers From user input and from file.
Convolution in Matlab The convolution in matlab is accomplished by using “conv” command. If “u” is a vector with length ‘n’ and “v” is a vector with length.
1 Lab 1. C Introduction  C: –Developed by Bell lab. in –a procedure-oriented programming language.  Developing environments: –Editing –Preprocessing.
Recap Saving Plots Summary of Chapter 5 Introduction of Chapter 6.
CS1109 L AB 3 July 3rd. R OAD M AP Homework submission Review How to use function and scripts While-end Finish last exercise Lab 2 Challenge questions.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Array Operations ENGR 1181 MATLAB 4.
CSC 111. Solving Problems with Computers Java Programming: From Problem Analysis to Program Design, Third Edition3 Solving Problems Stages 1.Problem.
CS 121 – Quiz Feb 17 th. Question 2 We want to count how many days there were such that the temperature is at least degrees lower than the.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
L AB 4 July 5th. F OR LOOP Exercise 1: Find two ways of “Summing all 1, 2, and 3 digit prime numbers.” Use for loop Hint: isprime, primes.
Physics 114: Lecture 1 Overview of Class Intro to MATLAB
Basic Principles Photogrammetry V: Image Convolution & Moving Window:
MATLAB – More Script Files
BAHASA PEMROGRAMAN MATLAB as an Engineering Tool & Programming Language a lecture note for Civil Engineering students of PETRA Christian University Doddy.
Modelling and Simulating Social Systems with MATLAB
CS1010 Programming Methodology
Basic operations in Matlab
MATLAB – Basic For Loops
CS005 Introduction to Programming
COMP 110 Loops, loops, loops, loops, loops, loops…
Communication and Coding Theory Lab(CS491)
Introduction to MATLAB Programming
MATLAB Tutorial ECE 002 Professor S. Ahmadi.
Matlab tutorial course
Programming Control Structures with JavaScript Part 2
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CSCE 206 Lab Structured Programming in C
Week 7: Computer Tools for Problem Solving and Critical Thinking
Matlab tutorial course
Presentation transcript:

Lab2 (Signal & System) Instructor: Anan Osothsilp Date: 07 Feb 07

Anan OsothsilpPage 1 Lab2 Date: 07 Feb 07 Objective: Introduce Matlab script working environment Learn how to write simple Matlab routine Learn how to write simple Matlab function Learn how to manage function file in Matlab environment

Anan OsothsilpPage 2 Lab Instruction: Follow the video tutorial and do Lab exercises Lab2 Date: 07 Feb 07

Anan OsothsilpPage 3 Function Format Function [arg1, arg2, …, argn] = FunctionName (arg1,arg2,…,argN) %program code here Function [y1, y2] = Process_signal (x1, x2) y1 = 2*x1; y2 = 3*x2; Lab2 Date: 07 Feb 07

Anan OsothsilpPage 4 Exercise 1 - Create function find_average to calculate the average value of input vector - Input_Vector = [1,3,5,7,9,11,12]; - Average = find_average(Input_Vector); Function output = Find average (input) x = sum(input); x2 = X/length(input); output = x2; Note: sum function is used to calculate summation of all elements for input vector length function is used to find the total number of elements of input vector Lab2 Date: 07 Feb 07

Anan OsothsilpPage 5 Exercise 2: let t = 0:0.01:10; input = 3*sin(2*pi*t); - Create function find_peak to calculate the maximum value of input vector Function output = Find_peak (input) // your code go here Hints: use max() function to find maximum value inside input vector alternative: Instead of using max function to find maximum value, Use for loop to find maximum number temp = 0; for i = 1: length(input) %this will loop from first to last element of input vector if input(i) > temp %if current value > temp then temp = input; % put it into temp end Lab2 Date: 07 Feb 07

Anan OsothsilpPage 6 Exercise 3 - Create function to process 3 input signal as depicted in by following figure x1 x2 x3 y1 y2Process_signal t= 0:0.01:10; x1 = sin(2*pi*1*t); x2 = sin(2*pi*2*t); x3 = sin(2*pi*4*t); Lab2 Date: 07 Feb 07