# Connexions

You are here: Home » Content » Freshman Engineering Problem Solving with MATLAB » Programming with M-files: Analyzing Railgun Data Using For Loops

### Recently Viewed

This feature requires Javascript to be enabled.

Inside Collection (Course):

Course by: Darryl Morrell. E-mail the author

# Programming with M-files: Analyzing Railgun Data Using For Loops

Module by: Darryl Morrell. E-mail the author

Summary: This is an example of using m-files to solve a simple engineering data analysis problem in which velocity and position of a railgun projectile are computed from acceleration data; the acceleration data is computed from the current driving the railgun.

## Note:

This example requires an understanding of the relationships between acceleration and velocity of an object moving in a straight line. A clear discussion of this relationship can be found in Acceleration; the Wikipedia article Motion Graphs and Derivatives also has an explanation of this relationship, as well as a discussion of average and instantaneous velocity and acceleration and the role derivatives play. Also, in this example, we will compute approximate integrals using the trapezoidal rule; The Wikipedia article Trapezium rule has an explanation of the trapezoidal rule.

## Velocity Analysis of an Experimental Rail Gun

A railgun is a device that uses electrical energy to accelerate a projectile; information about railguns can be found at the Wikipedia article Railgun. The paper Effect of Railgun Electrodynamics on Projectile Launch Dynamics shows the current profile of a railgun launch. The acelleration aa of the projectile (in units of ms2 m s 2 ) is a function of the current cc through the projectile (in units of kAmp). This function is given by the equation

a=0.0036c2sgnc a 0.0036 c 2 sgn c
(1)
where sgnc sgn c is 1 if c>0 c 0 and -1 if c<0 c 0 .

### Exercise 1

#### Get the data

Download the current data set in the file Current.txt onto your computer (right click on this link). The file is formatted as two columns: the first column is time in mili-seconds, and the second column is current in kA.

The following sequence of commands will load the data, create a vector t of time values, create a vector c of current values, and plot the current as a function of time.

t = Current(:,1);
c = Current(:,2);
plot(t,c)
xlabel('time (msec)')
ylabel('current (kA)')
The plot should be similar to that in Figure 1.

### Exercise 2

Compute the projectile velocity as a function of time. Note that velocity is the integral of acceleration.

## References

1. Alexander E. Zielinski; Paul Weinacht. (1999). Effect of Railgun Electrodynamics on Projectile Launch Dynamics. IEEE Transactions on Magnetics, 35(1), 118-123.

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

#### Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

#### Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks