Download presentation
Presentation is loading. Please wait.
1
Lab2 (Signal & System) Instructor: Anan Osothsilp Date: 07 Feb 07
2
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
3
Anan OsothsilpPage 2 Lab Instruction: Follow the video tutorial and do Lab exercises Lab2 Date: 07 Feb 07
4
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
5
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
6
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
7
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.