computer programming MATLAB
Plagiarism
Any plagiarism identified in assignments will be considered academic misconduct and academic penalties will apply. A definition of plagiarism from the Griffith Institute for Higher Education,
Good Practice Guide is attached.
Plagiarism can take any of the five following forms:
Verbatim copying
Copying word for word without any acknowledgement of the source
Incorrect/inadequate
Verbatim material incorrectly noted as having been paraphrased, or material that
acknowledgement:
has been paraphrased and has not been acknowledged adequately.
Collusion:
Copying material from another’s assignment with his/her knowledge.
Ghost writing:
Submitting an assignment as your own when it has been written by a third party.
Purloining or
Copying material from another’s assignment without his/her knowledge.
appropriation:
YOUR ASSIGNMENT
YOUR FINAL SUBMISSION:
- A REPORT document in IEEE Format – YOU MUST USE THE TEMPLATE. You cannot use any other template.
- ALL Matlab Code that implements your program.
YOUR FINAL ELECTRONIC SUBMISSION:
You should compress all the files and submit the compressed file.
To make sure you have included all required files: create a new directory (folder)
copy your matlab .m files to that directory copy your data to that directory
copy your report to that directory
Restart Matlab and switch to that directory. Make sure you can run your program. If your program will not run check that you have not left out files.
Once you are sure that ALL the required files (Report, *.m and data) are together in the one directory, compress that directory (using zip, rar, etc. In Windows you can right click and select compress folder)
YOU WILL SCHEDULE A TIME TO DISCUSS YOUR ASSIGNMENT
1004ENG Computing & Programming with Matlab 2014 S1 Assignment
This assignment requires some programming and plotting activities. The assignment requires some understanding of the discrete maths implementation of integration and differentiation (which will be explained)
SCENARIO:
Your assignment is based around data collected from some kind of sensor measuring 3D displacement or velocity or acceleration. You are required to convert from one of these kinematic types to the other types eg: if you are given displacement, then you would be converting to velocity AND acceleration. If you were given velocity then you would be converting to both acceleration AND displacement. If you were given acceleration then you would be converting to both velocity AND displacement
BACKGROUND MATH / PHYSICS
The position vector, r (or s), the velocity vector, v, and the acceleration vector, a are expressed using rectangular coordinates in the following way:
How are these related :
If r or v or a are described by functions then each is either the integral or the differentiation of another, as below, calculating v from the derivative of r and a from the derivative of v .
Conversely, as below, v is calculated as the integral of a , r is calculated as the integral of v .
BUT: in sensor based data, these are not continuous functions but discrete samples and the maths is completely simplified.
v i =
(r i−r i−1)
=(r i −r i−1)∗samplerate
t
In the above, the average velocity at a point in time, is the change in position ( r ) divided by
the change in time (
t ). The change in time is simply the inverse of the samplerate
(eg 1/samplerate). Using matlab, if the displacement samples are loaded in a vector, then to generate the velocity the vector is subtracted from a one sample shifted copy of itself and the resultant
matlab vector multiplied by the samplerate (eg t = 1/samplerate and dividing by t is the
same as multiplying by samplerate.
Eg: for a samplerate of 10 samples / sec
r=[0.15, 0.3, 0.45, 0.61, 0.77, 0.94, 1.1 ] (metres)
then we assume for the moment that r0 is zero and get:
v=[0.15-0, 0.3-0.15, 0.45-0.3, 0.61-0.45, 0.77-0.61, 0.94-0.77, 1.1-0.94]*samplerate
v=[1.5, 1.5, 1.5, 1.6, 1.6, 1.7, 1.6]
BUT: subtracting zero from the first sample can cause the first velocity (or acceleration) calculation to be anomalous. It is better to generate the differences between each pair of samples and the resultant data set will be one sample shorter than the source data.
To calculate the integral requires the summing of successive samples and multiplying by t (or
divide by the samplerate)
i
i
∑ v n
r i =∑ (v n
t )=
1
samplerate
1
for example, if the velocity vector was:
v=[ 1.5, 1.5, 1.5, 1.6, 1.6, 1.7, 1.6 ]
then
r=[1.5, 3.0, 4.5, 6.1, 7.7, 9.4, 11 ] /samplerate.
Each of you will receive an individual assignment in the form of some matlab data (a file called X01.mat or similar) This data will be zipped to allow it to pass through the mail system.
On many windows systems you cannot double click on a matlab mat file or it will start MS-ACCESS. You need to put your data in your matlab folder and follow the process below.
You can load this data using the load command. (use help to find out how)
Once the data is loaded you will be able to inspect the data. It is stored in an object called “ASSIGNMENT”. An example is below.
- load X42
ASSIGNMENT
ASSIGNMENT =
data: [3x4321 double] samplerate: 100
TimeSeriesIn: 'rows' units: 'm/s^2'
currentData: 'acceleration' requiredData: 'velocity' requiredUnits: 'm/s'
>>
>> ASSIGNMENT.data(:,1:6)
ans =
-0.0010
-0.0020
-0.0029
-0.0039
-0.0048
-0.0056
0.0049
0.0099
0.0151
0.0203
0.0257
0.0312
-0.0646
-0.1292
-0.1938
-0.2584
-0.3230
-0.3876
>>
In the above example, the data is in rows and represents acceleration. The student receiving this assignment is required to convert the data from acceleration to velocity AND to displacement..
(Note: in the above example, the variable ASSIGNMENT.currentData tells us that the data represents acceleration and is in m/s2.)
The important descriptors of the data are below.
data: [3x4321 double] samplerate: 100
TimeSeriesIn: 'rows' units: 'm/s^2'
currentData: 'acceleration'
Some students will also have instructions describing the X,Y & Z channels such as 'length', 'height', 'width'. In this case, these descriptors should be used in the appropriate places eg a 3D plot would include all 3 descriptors, one on each axis eg: height (m).
Ignore the fields “requiredData” and “requiredUnits”
Your final units should be metres (m) for displacement, metres-per-second (ms -1 ) for velocity and metres per second-squared (ms -2 ) for acceleration.
Your REPORT
You must process the data as required and present your results in a written document using the IEEE template on the portal*. Your report should follow the IEEE format. There is a dummy version of how your assignment might be put together and two actual IEEE conference papers that you can use as models.
*You will download the template and edit it. Delete the existing text as you write your own text. The template on the portal is a Microsoft Word docx file with track-changes turned on. When you submit your electronic file, it will be checked for the changes and the author.
Your report will be four pages long. You will include a fifth page with all 9 graphs listed below.
You Must Have (in your report):
Your report WILL include a flowchart and a structure chart describing your program.
Your results will include
- Check-sum of the 3 channels of original data. ((3 checksums) (sum of each channel data))
- Mean of each channel for each of the three steps (displacement, velocity, acceleration)
- Mean of the magnitude of the data for each of the three steps.
Your results will include the first three figures listed below and any additional figure of your choice. All the figures will appear in your additional page.
Figures your program must produce.
A figure with 3 sub-plots representing the 3 channels of original data. A figure with a 3D plot of the original data.
A figure with one plot with the magnitude of the original data. (vector length eg (sqrt(x^2+y^2+z^2)
(1st Processing Step eg velocity)(depends on your specific question)
A figure with 3 sub-plots representing the 3 channels of processed data. A figure with a 3D plot of the processed data.
A figure with one plot with the magnitude of the processed data.
(2nd Processing Step eg acceleration)(depends on your specific question) A figure with 3 sub-plots representing the 3 channels of processed data. A figure with a 3D plot of the processed data.
A figure with one plot with the magnitude of the processed data.
Each Graph MUST HAVE the axis labelled with the name and units (if no labels have been given, label the channels 'X', 'Y', 'Z'). The figure must be titled. Graphs need grid lines AND 3D plots need to have a 1:1:1 aspect ratio. (use “help” to understand this)
You must also provide your original matlab code. You must use built-in functions where possible except:
You must write your own function to produce the graphs (eg the graphing code only occurs once in a separate function m-file, not three times in your program.
You must write your own function to do the numeric integration (and/or differentiation) (eg the integration code is in a separate function m-file, not in your main program. These functions must use looping to perform their calculations.
For one type of graph of your choosing, write programming to add a special grid line marking some special value (such as a minimum value or a maximum value or mean value (something of significance)).
You can export your graphs automatically from your matlab code using a command similar to one used in Lab 2. eg: print(‘-dpng’,’q2a.png’);
Exporting your graphs will simplify importing them into your word processor..
Use the above list as a checklist. Make sure you include ALL the required information and outputs.
ASSIGNMENT CODING
The assignment will cover many areas of Matlab coding.
There will be a requirement to:
- load data
- inspect the data
- process the data
- display the data
- save the results
This will involve the following coding:
- for loops
- matrix manipulation
- use of statistical tools
- plotting (2D and 3D)
- use of built in functions
- use of your own functions
NOTE WELL:
In your programming you cannot use built in differentiation or integration functions but must make your own functions and perform the differentiation and / or integration using looping code.
Programming Hints:
To aid you in your programming here are a few summary points.
You will need a function that plots data.
- It will plot a figure with three subplots .
- It will plot a figure that represents a 3D representation of data.
- It will plot a 3D magnitude.
- The figures will all be labelled and titled.
- It will add additional useful information to a figure of your choice.
- It will save the figures to disk so you can import them to your word processor.
- Since your graphing function will be plotting data for three different types of input (displacement, velocity and acceleration) it not only needs to accept input data but also a text message of the data type.
You will need either one or two other functions; written by you, that do integration of a set of data or differentiation of data. If you receive velocity information you will require both functions, if you receive displacement or acceleration data, you will only require one of the two functions (which function depends on your data).
Your main program will call your functions to convert your data to the other two forms of the data and to plot the three figures associated with each of the three forms.
Because of the above, you will create 3 or 4 (or more if you wish) matlab “m” files.
Errors:
If any of your graphs are a straight line or two straight line segments then you have made a mistake. and confused a row for a column or visa-versa. Do not forget to include the check-sum and mean values. Make sure you can tick off every item in the checklist.
Marking:
On the previous page is a check list. For every item you don't supply, you lose marks.
If you don't supply the four page report with sensible text correctly formatted, spell-checked and grammar checked you lose marks.
If you copy code or text from another student you get NO marks.
If you purchase your assignment from the internet, another student or any other source you get NO marks.