4_Quarterman_Patrick_HW07A

4_Quarterman_Patrick_HW07A - TimeofGlitch=Time(Glitch%Lists...

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

View Full Document Right Arrow Icon
Patrick Quarterman Section 4 HW 7A Part 1: Script: %'HW07A1 Script' %Patrick Quarterman, Section 4 %Removes bad data from sensor data %Define Sensor data Time=[0:2:24]; %Time vector (seconds) Position=[2 5 378 8 633 12 18 24 974 35 56 257 89]; %Position Vector (meters) %Find bad data positions Bad_Data=find(Position>255); %remove bad data Time(Bad_Data)=[] Position(Bad_Data)=[] Command Window: >> run HW7A1 Time = 0 2 6 10 12 14 18 20 24 Position = 2 5 8 12 18 24 35 56 89 Part 2: Function script: function []=BadData(Time,Position) %Patrick Quarterma, Section 4 %Finds glitches in sensor data and replaces with corrected data %Inputs: 'Position' and Time as Vector %Outputs: Correct Data for time and position as vector Glitch=find(Position>255); %Finds location of bad data
Background image of page 1

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

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

Unformatted text preview: TimeofGlitch=Time(Glitch) %Lists time that glitch occurs %Create Upper and Lower Position and Average vectors Upper=Position(Glitch+1); %Defines Upper Position Lower=Position(Glitch-1); %Defines Lower Position Average=(Upper+Lower)/2; %Averages Upper and Lower %Replace glitch values with average values Position(Glitch)=Average; %Rename fixed data CorrectData=Position Command Window: >> Time=[0:2:24]; >> Position=[2 5 378 8 633 12 18 24 974 35 56 257 89]; >> BadData(Time,Position) TimeofGlitch = 4 8 16 22 CorrectData = Columns 1 through 8 2.0000 5.0000 6.5000 8.0000 10.0000 12.0000 18.0000 24.0000 Columns 9 through 13 29.5000 35.0000 56.0000 72.5000 89.0000...
View Full Document

Page1 / 2

4_Quarterman_Patrick_HW07A - TimeofGlitch=Time(Glitch%Lists...

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