gain experience in software development

FIND A SOLUTION AT Academic Writers Bay

2
Content
1. Introduction ………………………………………………………………………………………………………………………………3
2. Specification Analysis ……………………………………………………………………………………………………………….3
2.1: Input Analysis …………………………………………………………………………………………………………………..3
2.2: Output Analysis ………………………………………………………………………………………………………………..3
2.3: Output Analysis ………………………………………………………………………………………………………………..4
3. Programme Design ……………………………………………………………………………………………………………………4
3.1 Main Algorithm Descriptions ………………………………………………………………………………………………4
3.1.1 Algorithm Description to calculate the centre point ………………………………………………………….4
3.1.2 Algorithm Description to calculate the cover cell …………………………………………………………….4
3.2 Hierarchy Chart …………………………………………………………………………………………………………………..5
3.3 Data Table …………………………………………………………………………………………………………………………6
3.3.1 Data Table for the main function module ………………………………………………………………………..6
3.1.2 Data Table for sub_function_1: import_data ……………………………………………………………………7
3.1.3 Data Table for sub_function_2: datacreate ………………………………………………………………………7
3.1.4 Data Table for sub_function_3: choice1 ………………………………………………………………………….7
3.3.5 Data Table for sub_function_4: choice2 ………………………………………………………………………….8
3.3.6 Data Table for sub_function_5: dataplot …………………………………………………………………………8
4. Program Test (Validation Test) …………………………………………………………………………………………………..9
4.1 Input File Test ……………………………………………………………………………………………………………………9
4.2 Choice 1 Test …………………………………………………………………………………………………………………..10
4.3 Choice 2 Test …………………………………………………………………………………………………………………..11
4.4 Choice 3 Test …………………………………………………………………………………………………………………..12
5. Conclusion ……………………………………………………………………………………………………………………………..12
6. Appendix: Program Code ……………………………………………………………………………………………………….13
3
1. Introduction
The aim of doing this assignment is to gain experience in software development, which includes
specification analysis, program structure design, coding, testing, program integration and documentation.
Some skills are trained such as how to plot graphs, how to find a actual point in a matrix.
In this assignment, a MATLAB program is required to read coordinate values from a text file and perform the
required computation. The program should be able to achieve the following functionality:
Ask the use to provide a file name from which the data will be read.
If the user chooses option 1, then the r and z coordinate of the centre of a cell defined by its axial and
radial cell position will be calculated and displayed on screen.
If the user choose option 2, then the position of a cell that contains (whose area covers) the coordinate
point (r,z) will be identified and displayed on the screen.
If the user chooses option 3, the grid system (see example in assignment2_data_file.pdf ) is displayed in a
diagram.
2. Specification Analysis
2.1: Input Analysis
1) Input the path and name of data file which will be open from keyboard.
Note: Check whether
The user will be asked to input filename until a correct filename is entered.
2) Input the choices of option from keyboard
1. Choice 1, calculate the centre of a cell and radial cell position and display it on the screen.
2. Choice 2, identify the position of a cell that contains the coordinate point (r,z) and display it on the
screen.
3. Choice 3, display the grid system in a diagram.
4. Exit the whole program
3) If the user chooses option 1:
Input: Input any point position (r,z) from keyboard.
Note: Check whether the input point is out of range, if it is out of range
The user will be asked to input position until a correct filename is entered.
4) If the user choose option 2,
Input: Input any coordinate point (r,z)
2.2: Output Analysis
1) Input the path and name of data file which will be open from keyboard.
Check whether the file can be found, if not, output
The user will be asked to input filename until a correct filename is entered.
2) Output user menu
3) If the user chooses option 1:
Check whether the input point is out of range, if it is out of range, output
4) If the user chooses option 2:
Output the entered point position on the screen.
Output the centre point (r, z) coordinate of the cell defined by the entered position on screen.
4
5) If the user chooses option 3,
Output: output the grid system is displayed in a diagram.
6) The menu choice is not 1-4, i.e. other input options are entered,
Output error and let the user to re-choose until the option 1-4 are choose.
2.3 Main Tasks
1. Use switch to enter each choice sub-module.
2. Load data form computer
3. Check the input file name
4. Check the range of input point position for choice 1
5. Check the range of input point pair (r,z) for choice 2
6. Plot grid system for choice 3
7. Calculate the r and z coordinate of the centre of a cell defined by its axial and radial cell position
8. Calculate the position of a cell that contains the coordinate point (r,z)
3. Programme Design
3.1 Main Algorithm Descriptions
3.1.1 Algorithm Description to calculate the centre point
Figure 1: Explanation for the centre point of quadrilateral ABCD
Figure 1 shows a quadrilateral, A, B, C, D is the midpoint of segment P1P2, P3P4, P2P3 and P1P4,
respectively. As both AD and BC are parallel to P1P4, both AD and BC equals the half length of P1P4. Hence,
quadrilateral ABCD is a parallelogram. Hence point (Z,R) can be calculated as the average value of point
A,B,C and D.
5
3.1.2 Algorithm Description to calculate the cover cell
Figure 2: Explanation for point (zin,rin) cover cell of ABCD
As shown in figure 2, (zin,rin) is the input point from the key board. Draw the vertical line and horizontal line
of point (zin, rin), which is line AB and line CD, respectively. Check whether line AB and line CD has the
cross points with line P1P2, P3P4, P2P3 and P1P4. If z1<=zin<=z2, and r1<=rin<=r2, it must be in the cell
P1P2P3P4.
3.2: Hierarchy Chart
xyz
(main program)
Explanations of each module:
xyz
Main function to achieve all the requirements
import_data
Sub_function_1:Import the whole data provided on Vital
datacreate
Sub_function_2:Select the useful data from the import file
choice1
Sub_function_3: Calculate the centre of a cell and radial cell position and display it on
the screen.
choice2
Sub_function_4: identify the position of a cell that contains the coordinate point (r,z)
and display it on the screen.
dataplot
Sub_function_5:Plot the grid system in a diagram
Reasons to divide the program into such modules: The first step is to import the total file, and then the useful
data should be peaked out. Then as the three choices are not quite related to each other, each of them can be
written as a function.
6
3.3 Data Table
3.3.1 Data Table for the main function module
Variable
name
Data type
Comment
Input/output
data
Double
Matrix
The total data provided on Vital,
Size 2397X5
From file
textdata
String
The first line in the datasheet provided on
Vital
Size: 1X1
From file
filename
String
The input file name
From keyboard
zvalue1
Double
Matrix
Pick all the useful Z value
Size: 1X1891
Data passed among sub-functions
rvalue1
Double
Matrix
Pick all the useful R value
Size: 1X1891
Data passed among sub-functions
zvalue1mat
Double
Matrix
Reshape Z value
Size: 31X61
Data passed among sub-functions
rvalue1mat
Double
Matrix
Reshape R value
Size: 31X61
Data passed among sub-functions
choice
Double
Although the automatic type of choice is
double, but integer is preferred, otherwise
error message may display.
From keyboard
3.3.2 Data Table for sub_function_1: import_data
Variable
name
Data type
Comment
Input/output
data
Double
Matrix
The total data provided on Vital,
Size 2397X5
From file
textdata
String
The first line Size: 1X1
From file
filename
String
The input file name
From keyboard
a b c d e f
Double
Matrix
a b c d g f, each of them is a 1X5 array, used
to pick the first 30 values in Z and R block
variable
g
Double
Matrix
g is a 1X1 array, used to define the 31th
value in Z and R block
variable
zvalue
Double
Matrix
zvalue is a 1X31 array
variable
rvalue
Double
Matrix
rvalue is a 1X31 array
variable
zvalue1
Double
Matrix
Pick all the useful Z value
Size: 1X1891
variable
rvalue1
Double
Matrix
Pick all the useful R value
Size: 1X1891
variable
7
3.3.3 Data Table for sub_function_2: datacreate
Variable
name
Data type
Comment
Input/output
zvalue1
Double
Matrix
Pick all the useful Z value
Size: 1X1891
Input from sub-function import_data
rvalue1
Double
Matrix
Pick all the useful R value
Size: 1X1891
Input from sub-function import_data
zvalue1mat
Double
Matrix
Reshape Z value
Size: 31X61
Output data will be used as input of
sub-functions. i.e. choice1, choice 2 and
datapolot
rvalue1mat
Double
Matrix
Reshape R value
Size: 31X61
Output data will be used as input of
sub-functions. i.e. choice1, choice 2 and
datapolot
3.3.4 Data Table for sub_function_3: choice1
Variable
name
Data type
Comment
Input/output
zvalue1mat
Double
Matrix
Reshape Z value
Size: 31X61
Input from sub-function datacreate
rvalue1mat
Double
Matrix
Reshape R value
Size: 31X61
Input from sub-function datacreate
CellZ
Double
The position
Output on the screen
CellR
Double
The position
Output on the screen
Z
Double
The centre
Output on the screen
R
Double
The centre
Output on the screen
r1
Double
Centre value r1 of line section P1P2
variable
z1
Double
Centre value z1 of line section P1P2
variable
r2
Double
Centre value r2 of line section P3P4
variable
z2
Double
Centre value z2 of line section P3P4
variable
r3
Double
Centre value r3 of line section P2P3
variable
z3
Double
Centre value z3 of line section P2P3
variable
r4
Double
Centre value r3 of line section P1P4
variable
z4
Double
Centre value z4 of line section P1P4
variable
Figure 3: Explanation for the centre point of quadrilateral ABCD
8
3.3.5 Data Table for sub_function_4: choice2
Variable
name
Data type
Comment
Input/output
zvalue1mat
Double
Matrix
Reshape Z value
Size: 31X61
Input from sub-function datacreate
rvalue1mat
Double
Matrix
Reshape R value
Size: 31X61
Input from sub-function datacreate
zin
Double
Input value for z
Input from keyboard
rin
Double
Input value for r
Input from keyboard
r1
Double
r1 value on line P2P3
Variable
z1
Double
z1 value on line P1P2
Variable
r2
Double
r2 value on line P1P4
Variable
z2
Double
z2 value on line P3P4
Variable
Figure 4: Explanation for point (zin,rin) cover cell of ABCD
3.3.6 Data Table for sub_function_5: dataplot
Variable
name
Data type
Comment
Input/output
zvalue1mat
Double
Matrix
Reshape Z value
Size: 31X61
Input from sub-function datacreate
rvalue1mat
Double
Matrix
Reshape R value
Size: 31X61
Input from sub-function datacreate
zvalue1mat1
Double
Matrix
Transpose of zvalue1mat
Size: 31X61
variable
rvalue1mat2
Double
Matrix
Transpose of rvalue1mat
Size: 31X61
variable
9
4. Program Test (Validation Test)
4.1 Input File Test
Figure 5: Test for file input
As we can see from figure 5, the program will ask the user to input the path and file name first. If the data
file in under the same path of the m-file, only the file name is needed.
If the file is not found, the user should check the path and file name.
The program will break the loop until the correct file is entered.
When the file name is input correctly, the user menu will appear on the screen.
The user menu will appear after each choice, until integer 4 is entered.
10
4.2 Choice 1 Test
Figure 6: Test for choice 1
As we can see from figure 6, this is the test for choice 1.
Choice 1 is to calculate the centre point of cell.
The user should input the row position from the keyboard first, whose range is between 0-30.
If the input value is out of range, the value has to be re-entered, until it is inside 0-30.
Then the user should input the column position from the keyboard, whose range is between 0-60.
If the input value is out of range, the value has to be re-entered, until it is inside 0-60.
After calculation, the cell position and the centre point of this cell will show on the screen
11
4.3 Choice 2 Test
Figure 7: Test for choice 2
Figure 8: Test for choice 2
Figure 9: Test for choice 2
Choice 2 is to calculate the cover cell
of the input point.
Input the Z value and the R value.
For the normal case, if the input point
is inside a certain cell, the output
information is shown in Figure 7.
Input the Z value and the R value.
If the input point is out of the cell
range, the output information is shown
in Figure 8.
It shows that the cover cell is not
found.
Input the Z value and the R value.
If the input point is the data provided
by the datasheet, the output
information is shown in Figure 9.
It shows that the position is provided
by data file (M, N).
12
4.4 Choice 3 Test
Figure 10: Test for choice 3
Choice 3 is to plot the figure for the grid system, which is Figure 10. When use axis auto command, the
grid system will show as below (Figure 11).
Figure 11: Scaling of Choice 3
5. Conclusion
By doing this assignment, firstly, the experience is gained in software development, which includes
specification analysis, program structure design, coding, testing, program integration and documentation.
Secondly, some skills of matlab are trained such as how to plot graphs, how to find an actual point in a
matrix.
13
6. Appendix: Program Code
14
15
16

YOU MAY ALSO READ ...  Unit 4 IP – The challenging concept of ensuring security
Order from Academic Writers Bay
Best Custom Essay Writing Services

QUALITY: 100% ORIGINAL PAPERNO PLAGIARISM – CUSTOM PAPER