Exam 1 Cheat Sheet

Exam 1 Cheat Sheet - Write a Matlab function called...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Write a Matlab function called peak_find that finds the two highest values in the input signal. There is one input to this function ( signal ) and one output ( peak_loc ). signal is a vector with two distinct peaks (similar to an R-peak in an ECG signal). peak_loc is a vector of the two index locations in signal of the two highest values. You do not need to comment your Matlab code. Also, please note that exact syntax is not critical (e.g. inserting or omitting a semi-colon at the end of each line is not important). function [peak_loc] = peak_find(signal) maxs = max(signal); signal_index = find((signal >= (0.65*maxs))); diff_index = diff(signal_index); interval = find(diff_index >1); index1 = signal_index(1):signal_index(interval(1)); [val1 peak1] = max(signal(index1)); index2 = signal_index(interval(1)+1):signal_index(length(signal_index)); [val2 peak2] = max(signal(index2)); peak_loc = [index1(peak1) index2(peak2)]; Thus, we can get the simulated time with the function calls: where after these calls, timeA and timeB will have the simulated times for driving by route A
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/31/2008 for the course ENGE 1104 taught by Professor Dr.bell during the Spring '08 term at Virginia Tech.

Page1 / 2

Exam 1 Cheat Sheet - Write a Matlab function called...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online