0% found this document useful (0 votes)
3 views

SIP Assignment 1

The document outlines various programming tasks involving mathematical computations and signal generation using LabVIEW and MATLAB. It includes generating sequences of numbers, checking for prime numbers, sorting integers, and manipulating arrays to compute sums based on indices. Additionally, it describes creating sinusoidal signals and visualizing them on a graph.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SIP Assignment 1

The document outlines various programming tasks involving mathematical computations and signal generation using LabVIEW and MATLAB. It includes generating sequences of numbers, checking for prime numbers, sorting integers, and manipulating arrays to compute sums based on indices. Additionally, it describes creating sinusoidal signals and visualizing them on a graph.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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.

2. Build a VI to check whether a given positive integer n is a prime number


and display a warning message if it is not a prime number.

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.

4. Build a VI to sort N integer numbers (positive or negative) in ascending


or descending order.

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

Rewrite this program without using a for loop.

The program returns the absolute value of all the numbers inserted by the for
loop.

4
7.

The program generates a vector t of length 1000 using the rand


function. If each value of the array is greater than 0.2, 0.2 will
be added to the output array, otherwise -0.2 will be added to
the output array. The output is graphically displayed using a
plot.

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

You might also like