Lab-II辅导、讲解SPSS留学生、辅导Python,Java编程语言、讲解c/c++ 讲解留学生Processing|讲解R语言编程

- 首页 >> OS编程
LABORATORY EXERCISE (Lab-II)1
Lab-II: Signal Processing Software System (SPSS)
Concepts and syntax to be used: Random number generation,
looping and control, arrays, comparison operations, linear search
operations
Problem Statement: In this assignment, a slow time-varying
random signal is sampled and the sampled values are stored in a
linear array for processing. A number of operations are then
performed on the stored values.
Design and implement a program that does the following
operations.
General instructions: First read the entire document carefully
before you begin designing your solution. There are TWO
PARTS in this problem. READ both the parts first and then
decide on your design.
Flow-Chart: After reading both the parts, draw a
FLOW_CHART capturing your design. Your code will be
verified if it follows the flow-chart design.
Clearly write comments for your code. Comments carry marks.
This question uses a random generator and hence the values in
your array will be different from the sample output. The sample

1 TE2101/TEE2101 Programming Methodology Exercise for Lab II for Sem 2 AY18/19; 2
output is only for you to know the format and type of output
expected.
PART I: Follow all the steps in that order indicated.
Consider an integer array Signal_A[] that can store 100 integer
numbers in the range -10 to +10.
(A) Signal Generation: Use the given code skeleton at the
end of the problem statement on Page 4 to generate these
random integers and store in the Signal_A[] array.
Print this Signal_A[] array first; This is your base
sampled signal.
Sample output:
[-7 0 8 5 6 -4 0 -1 4 4 -3…..]
(B) Max & Min Search Operation: Using this Signal_A[]
array to a search for maximum and minimum values from
this array of 100 integers; Print your output max and min
values; If there are more than one maximum and minimum
values it is sufficient if you print just once the values.
Sample output:
Max: 8
Min: -3
(C) Zero Count Operation: Use this above Signal_A[] array
to perform a Zero_Count operation which counts the 3
number of zeros and the indices where they occur in the
list and print your results. While counting you need to
report the number of zeros from 0 to 49 and 50 to 99
separately as indicated below.
Sample output:
Zero at indices: 0, 1, 5, 6, 7, 10, 27… 43, 57, 65, 66,
87….
Total zero count = 53
Total zero count_A_0_49 = 23
Total zero count_B_50_99 = 30
(D) Filtering Operation: Use the original array Signal_A[]
and do a Zero_Bias operation which replaces all the
negative values to 0. Count the number of negative values
and then replace them with zeros. You may choose to do
this together! Save this array as a Zero_Bias_A[] array;
Display the number of negative values in the Signal_A.
Print this Zero_Bias_A[] array.
Sample output:
Number of negative values: 27
Zero_Bias_A = [0 0 8 5 6 0 0 0 4 4 0…..]
PART II: Now generate a new Signal_B – Repeat all the parts
(A) to (D) above. Determine the following:
(i) Display the percentage difference between Zero
Counts (Part I.C) between Signals A and B;
(ii) Display which signal has more zeros in the interval 0 to
49 and in the interval 50 to 99.4
(iii) Display the difference between the respective max
values and respective min values between the signals.
(max of A – max of B; min of A - min of B)
NOTE: For Part II you need to decide how you wish to present
your results, as this is a design issue.
Flow-Chart: By now you must have read both the parts.
Draw a FLOW_CHART capturing your design. Your Code
will be verified if it follows the flow-chart design.
Skeleton Code for Random Number generator [-10,10]
NOTE: Only skeleton code is given here for your guidance.
int main()
{
int toss;
srand((unsigned int)time(NULL));
/* Generate random numbers in the range [-10,10] */
for (int i=0;i<20;i++){
// toss a coin here
// If head, then generate a -ve num & a 0

else // +ve num & a 0

}
return 0;
}

站长地图