SIP Assignment 1
SIP Assignment 1
A for loop is used to generate 1,000 numbers in a sequence. Since the for loops run a
fixed number of iterations, it is possible to generate numbers that may follow a certain
pattern.Once the data set is developed, appropriate mathematical functions compute
variance. These math functions calculate how much the individual numbers in a data set
differ from their mean value. Therefore, calculating the average of these squared
differences in variance forms an essential step.
To check the given positive integer n is a prime number use numeric control and a prime
function as an input and round LED as an output indicator.
1
3. Build a VI to generate the first N prime numbers and store them using
an indexing array. Display the outcome.
A for loop is used to generate N prime numbers in a sequence and store them
in an indexing array. To do so, an array of only prime numbers has been
created using two for loops with one having a conditional terminal.
To sort the given N integer n in ascending or descending order use array control and a
build array is used to obtain the outcome of indexing array.
2
5. Write a .m file code to add all the numbers corresponding to the even
indices of an array. For instance, if the array x is specified as x = [1, 3, 5,
10], then 13 (= 3+10) should be returned. Use the program to find the sum
of all even integers from 1 to 1000. Run your code using the LabVIEW
MathScript interactive window. Also, redo the code where x is the input
vector and y is the sum of all the numbers corresponding to the even
indices of x.
3
6. Explain what the following .m file does:
L=length(x);
for j=1:L
if x(j) < 0
x(j)=-x(j);
end
end
The program returns the absolute value of all the numbers inserted by the for
loop.
4
7.
5
8. Build a hybrid VI to generate two sinusoidal signals with the
frequencies f1 Hz and f2 Hz and the amplitudes A1 and A2,
based on a sampling frequency of 8000 Hz with the number of
samples being 256. Set the frequency ranges from 100 to 400
Hz and set the amplitude ranges from 20 to 200. Generate a
third signal with the frequency f3 = (mod (lcm (f1, f2), 400)+
100) Hz, where mod and lcm denote the modulus and least
common multiple operation,respectively, and the amplitude A3
is the sum of the amplitudes A1 and A2. Use the same
sampling frequency and number of samples as specified for
the first two signals. Display all the signals using the legend
on the same waveform graph and label them accordingly.
The program has been developed to generate three sinusoidal signals ranging
from 100 to 400Hz. The signals are based on a sampling frequency of 8000 Hz
and 256 samples. The third signal’s frequency is calculated where its
amplitude is the sum of the first two.
6
7