Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Forward, Central, and Backward difference equations above to calculate acceleration in % the y-direction: AccelY I need help setting up the Matlab equation for

Use Forward, Central, and Backward difference equations above to calculate acceleration in % the y-direction: AccelY

I need help setting up the Matlab equation for calculating the aceleration of gravity, which I Bolded down below, the rest is context on how to set up formula,

Initial Set-up:

1. Create a folder called BME452Lab and copy the Matlab script files (files ending in .m) and the data files (files ending in .trc) into the folder. All of the files need to be in the same folder.

2. Start/Open Matlab

3. From the File menu select Set Path

4. In the Set Path window, select Add Folder. Navigate to the BM452Lab folder and press Open. Select the Close button to close the Set Path window. Matlab will now know where to look to find your files. Open the sticktoss.trc file using Excel. Save the trc file as sticktoss.xlsx format. Look at the header, it provides information on the data collection and markers. Notice also the column names (rows 4 and 5). X1, Y1, and Z1 are the x, y, and z position coordinates for marker 1 at each measured time (column B). Now import the sticktoss.xlsx file into Matlab.

To import sticktoss.xlsx using command importdata. For examplea = importdata ('C:\Users\j986k765\Desktop\BME 452\sticktoss3.xlsx'); where a is a variable representing a structure, importdata is a function to import Excel files into Matlab (see also xlsread), and all of the words inside the parenthesis is your file directory and filename.

After importing data, you have to find the average of the Y coordinate (Y is vertical axis). For example: you have two markers such as marker 1 and marker 2. Take the average of the Y coordinate for the two markers: Yave = (Y1+Y2)/2. Now you have to find the first derivative to calculate the velocity. To find the velocity you can use the forward difference, central difference or backward difference method, or all three together.

The following equations can be used to find the forward difference, central difference and backward difference respectively-

1. Forward Difference = (Yave2 Yave1)/(Time2 Time1)

2. Central Difference = (Yavei+2 Yavei)/(Timei+2 Timei)

3. Backward Difference = (Yaven Yaven-1)/(Timen Timen-1)

After calculating Velocity you have to find the acceleration. To find the acceleration you have to repeat the velocity procedure again.

The following Matlab code can be used to find both velocity and acceleration.

Matlab Code

% the percent sign indicates a comment information that is not processed by Matlab

% clear the command window screen (clc), all variables (clear all), and close all figure

% windows (close all)

clc clear all

close all

%

% Import data from excel file and save it in structure a and field .data %%

a = importdata ('C:\Users\j986k765\Desktop\BME 452\sticktoss3.xlsx');%

type path to your file % to view the data, in the command window type a.data and hit enter a.data % the NaN in the file header area stands for not a number time = a.data(7:end,2);

% creates a variable time from all the data in the 2nd column of a.data Marker1Y = a.data(7:end,4);

% creates a variable Marker1Y of the marker 1 y coordinate data Marker2

Y = a.data (7:end,7);

CoMY = (Marker1Y + Marker2Y)/2; % calculates the y coordinate of the stick center of mass

% Filter would go here % Use a numerical method to calculate the derivative of the discrete data. Essentially, we % will calculate variations of x/t, %

Forward difference first derivative: v1 = (x2 x1)/(t2 t1)

% Use for first row derivative calculation

VelY(1,1) = (CoMY(2,1) - CoMY(1,1))/(time(2,1) time(1,1));

% Central differences first derivative: vi = (xi+1 xi-1)/ (ti+1 ti-1) %

Use for 2nd row through 2nd to last row len = length(time);

% determine the number of rows of data

VelY(2:len-1,1) = (CoMY(3:len,1) - CoMY(1:len-2,1))./(time(3:len,1) time(1:len-2,1));

% Backward differences first derivative: vlast = (xlast xlast -1)/(tlast tlast -1)

% Use for last row derivative calculation VelY(len,1) = (CoMY(len,1) - CoMY(len-1,1))/(time(len,1) time(len-1,1));

%Acceleration% % Use Forward, Central, and Backward difference equations above to calculate acceleration in % the y-direction: AccelY

% Save data PosVelAccel = [time, CoMY, VelY, AccelY]; xlswrite ('C:\Users\j986k765\Desktop\BME 452\stick_CoM_Pos_vel_Accel.xlsx', PosVelAccel);

Plots figure(1); plot (time,CoMY); figure(2); plot (time,VelY); figure(3); plot (time,AccelY); figure(4); plot (time,CoMY); hold on plot (time, Marker1Y, m); plot (time, Marker2Y, g); hold off figure(5); plot (time,CoMY); hold on plot (time,VelY, r); plot (time,AccelY, m); hold off

% For those interested, you can filter the CoMY position data before taking the derivative using [B, A] = butter(4, 5/30); % generates coefficients for 4th order Butterworth filter with 5Hz cutoff frequency CoMY = filtfilt(B, A, CoMY);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions