Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Mathematics of radio engineering wikipedia , lookup

Law of large numbers wikipedia , lookup

Volume and displacement indicators for an architectural structure wikipedia , lookup

Large numbers wikipedia , lookup

Collatz conjecture wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Addition wikipedia , lookup

Elementary mathematics wikipedia , lookup

Order theory wikipedia , lookup

Transcript
Introduction
1. Build a virtual instrument that add and multiply two numbers given on the front panel.
2. Build a virtual instrument that calculates area of an isosceles triangle giving the basis
side and a basis angle.
3. Build a virtual instrument that calculates the product and the quotient of two complex
numbers. Verify manually the calculus.
4. Build a virtual instrument that calculates the polar co-ordinates of a complex number.
Verify manually the calculus.
5. a) Build a VI that generates 1000 samples of Gaussian noise with σ = 1.
b) Determine mean, standard deviation and variance.
c) Build the histogram using the express VI in Mathematics-Probability & Statistics
subpalette and observe the normal distribution of the noise samples.
d) Generate 1000 samples of white noise of amplitude 3 and solve b) and c).
SubVI
1. Build a subVI that generates a random number between two numbers given as inputs.
2. Build a subVI that converts radians in degrees or degrees in radians, depending on a
Boolean given as input.
Boolean
True: rad  degree
False: degree  rad
Arrays
1. Build a 6-elements 1D-array and a 4x5 2D-array. Give them arbitrary elements.
Perform the following:
a. Determine array size for each array. Discuss the result.
b. Calculate the transpose.
c. Extract the element corresponding to index 2 from the 1D-array. Extract the
element corresponding to (1,2) index of the 2D-array.
d. Extract the second line of the 2D-array. Extract the third column of the 2Darray.
e. Transform the 2D-array into an 1D-array in which the elements are the lines of
the 2D-array concatenated in order: 1st-line, 2nd-line, 3rd -line, 4th -line.
f. Transform the 2D-array into an 1D-array in which the elements are the
columns of the 2D-array concatenated in order: 5th -column, 4th -column, 3thcolumn, 2nd-column, 1st -column.
g. Separate a 2x3 2D-array from the initial 4x5 in which the first element is the
(1,1) index element of the initial array.
h. Replace the first element of the 4x5 array with 45.
i. Replace the first 3 elements of the 2nd line with 100, 101 and 102.
j. Replace the first 3 elements of the 3rd column with 100, 101 and 102.
k. Insert between the 2nd and the 3rd columns a new one of which the first 2
elements are 100 and 101. What happens with the other elements?
l. Extract from the initial 2D-array the 2nd and the 3rd columns.
m. Convert the 4x5 2D-array into a 2x3 2D-array using Reshape array. Notice
how is done. Add a new dimension. How are the elements ordered?
2. Practice polymorphic operations with arrays:
a) add a scalar with an array
b) add two arrays of same dimensions and same number of elements
c) add two arrays of same dimensions and different numbers of elements
d) add two arrays of different dimensions.
3. Find the fractional indexes corresponding to the number 0.5 in the following array
considering a linear interpolation between adjacent numbers:
4. Find the interpolated value corresponding to the fractional index 2.7 in the above
array, considering a linear interpolation between adjacent numbers.
5. Find the interpolated value corresponding to the fractional index 2.7 in the above
array, considering a polynomial interpolation between adjacent numbers (use a
function in the Mathematics subpalette).
6. Find the interpolated value corresponding to the fractional index 2.7 in the above
array, considering a spline interpolation between adjacent numbers.
Structures
1. Build a VI that generates a 1D-array containing all the natural numbers up to 150
using:
a. FOR loop
b. WHILE loop
2. Build a VI that generates a 1D-array containing, in order, integers between two given
numbers set on the front panel using:
a. FOR loop
b. WHILE loop
3. a) Build a VI that generates, continuously, random integers between two integers
given on the front panel, at equal intervals of time.
b) Stop the VI when the generated number coincides with a number given on the front
panel.
c) Display the number of attempts until the coincidence.
d) Display the time elapsed until coincidence.
4. a) Build a VI that generates a 1D-array containing N random integers between Nmin
and Nmax, where N, Nmin and Nmax are set on the front panel.
b) Determine and display how many times the elements of the array coincide with a
given number.
c) Build a 1D-array containing the indexes of the coincidences.
5. Build a VI that counts how many times the user pressed an OK button on the front
panel using:
a. WHILE loop
b. EVENT structure
6. a) Build an infinite impulse response digital filter having the following recursive
difference equation:
y(n)  1.3x(n)  x(n  1)  x(n  2)  0.5 y(n  1)  1.1y(n  3)
b) Determine the response of this filter to an input signal x(n) composed of 100
random numbers between -2 and 2.
7. a) Build a 1D-array containing 20 random numbers between two given numbers, Nmin
and Nmax.
b) Separate this array into two other 1D-arrays, one containing the elements above a
given number, N, and the other the elements under N. Display on the front panel the
initial vector and the sorted vectors.
8. Build a VI that does the following:
a. First, build a 1D-array containing, in order, all integers between -20 and 20.
b. Next, build a new 1D-array containing the elements of the first 1D-array in
random order.
9. a) Build a VI that continuously generates random numbers between -50 and 50 at
intervals of 100 ms.
b) “Catch” into a 1D-array only the numbers between -10 and 10.
c) Display permanently how many numbers have been “cached” and how many have
been “lost”.
10. a) Build a VI that continuously generates random numbers between 1 and 5, at 100 ms
intervals.
b) Put a color box on the front panel and color it according to the following rules:
 1<n<2
red
 2<n<3
yellow
 3<n<4
blue
 4<n<5
green
11. Build a real matrix having 2 lines that contains:
1. on the first line all the even numbers between two numbers given on the front
panel
2. on the second line all the odd numbers between two numbers given on the front
panel
12. Build a VI that calculates and displays all the divisors of a given number.
13. Build a VI that displays all the prime numbers up to a given number.
14. a) Build a MxN 2D-array (M and N are set on the front panel) containing random
integers between 0 and 50.
b) Display how many times the array elements coincide with an integer between 0 and
50 given on the front panel and replace those elements with 51.
15. a) Build a VI that simulates throwing of 2 dices.
b) Display how many times someone threw a certain value of the sum of the dices in a
throwing session. See the front panel below.
Exercise 15
16. a) Build a VI that generates a 1D-array containing N random integers between two
limits set on the front panel.
b) Build a new 1D-array whose elements are the products of the successive elements
of the first array, taken 2 by 2, i.e. the first element of the second array is the first
element of the first array multiplied by the second element of the first array, the
second element of the second array is the second element of the first array multiplied
with the third element of the first array, etc.
c) Extend the problem to products of three elements.
17. a) Build a VI that generates continuously random numbers between 1 and 4.
b) Calculate and display, at equal periods of time, mean, standard deviation and
calculate and display the histogram.
Event structures
1. On the front panel of a VI, add the following: a) a Boolean button named “Buton 1”,
b) a Boolean button named “Buton 2”, c) a slide named “Slide”, d) a STOP button
named “stop” and e) a string indicator, like in the figure below.
Build the block diagram for fulfilling the following functions:
3. When pushing Buton 1, the string indicator displays “Button 1 is pressed”.
4. When pushing Buton 1, the string indicator displays “Button 1 is pressed”.
5. When moving the slider, the string indicator displays “The slider has been moved.
The value is … [two digits of precision]”
6. When clicking somewhere on the front panel, the string indicator displays: “One
clicked on …x…, …y… point”
7. When hitting a key, the string indicator displays: “One hit the key: …..”
8. When pushing STOP button, the string indicator displays “STOP button is
pressed”
Strings
1. Using the Scan From String function, extract all the numbers contained in the
following strings:
Ora este 12.45. Azi suntem in 14/11/2013. Apa are 24.5
grade. Sarcina electronului este 1.6e-19 C.
Temperature is 27.3 degrees. The book costs 30.5 lei.
Number PI is 3.141592653.
2. On the front panel, a 1D numerical array composed by 10 elements of arbitrary values
is given. Build, using the function Format Into String, the text:
Array elements are:
[e1] & [e2] & …………… [e9] & [e10]
3. Place on the front panel a digital control and give it an arbitrary number. Display on a
string indicator the following text:
The number is: …….
Today is [today date, e.g. Wednesday, 12/02/2014]
Time is: [current time].
4. Build a VI that replaces a given group of characters in a text set on a string control on
the front panel, with another group of characters that represents a number given on the
front panel.
5. Build a VI that displays in a 1D-array all the real numbers found in a given text on the
front panel.
6. Build a VI that extracts from a given text all the words beginning with letter a and
display them in a string 1D-array.
7. Build a VI that displays in a table, on columns, the values of the following functions:
f 1( x)  x 2  log( x)  1
f 2( x)  2 sin(x / 180 )
f 3( x)  x 3  x
for all x integers in the range 2 to 25.
The header of each column contains the function name
8. Build a VI that order alphabetically, in a single column, the words in the following
table:
9. Build a VI that displays in a table, on M rows and N columns, random integers
between 10 and 50. Next, find all the coincidences of a given number, K, with the
numbers in the table and display the number of coincidences and the coordinates of the
table cells where the coincidences have been found.
M, N and K are set on the front panel.
Variables
1. a) On the block diagram of a VI, include two While loops with which one displays on
two numerical indicators the values of index i at every 200 ms, like in the figure.
b) Try to stop them simultaneously.
2. Build the same loops in two different VIs. Try to stop them simultaneously.
3. Let’s have three VIs named Main.vi, Odd.vi and Even.vi. They have to do the
following: the Main.vi generates random integers between 0 and 100 at intervals of 1
s. When the generated number is odd, the Boolean indicator on the front panel of
Odd.vi is turned on. When the generated number is even, the Boolean indicator on the
front panel of Even.vi is turned on and the indicator on the Odd.vi is turned off. All
the three VIs may be stopped from a STOP button on the FP of Main.vi.
4. Solve the same problem as the previous, but instead of light indicators on Even.vi and
Odd.vi, they contain a 1D-array each, that are filled out with even, respectively odd
elements generated by Main.vi. The elements are added to the arrays as soon as they
are generated.
Graphical indicators
1. Build a VI that generates two waveforms, a sin and a cos, given the following
parameters: N – total number of samples, Np – number of periods, A – amplitude, in
two modes:
a. using a Formula Node
b. using the function generator found in the Signal Processing palette
For using the Formula Node, start from the analytical representation of the two
functions:
N p1 

y1(i )  A1sin  2
i
N 

N p2 

y 2(i )  A2 cos 2
i
N 

In the above formula, i is an indexed variable taking integer values from 0 to N-1.
2. Draw the waveforms of the above function on the graphical indicators: Waveform
Graph, Waveform Chart and XY Graph and study the properties and facilities of these
indicators.
3. Draw on an XY Graph a square giving on the front panel the length of a side and the
Cartesian coordinates of the upper left corner.
4. Draw on an XY Graph a circle giving on the front panel the radius and the coordinates
of the centre.
5. a) Build a VI that generates and draw on the same graph the functions:
y1 = x3 + mx2 + 1
y2 = ax + b
for al the integer values of x between two numbers, Nmin and Nmax.
You provide on the FP the values of a, b and m.
b) Graphically find the solutions of the equation
y1 = y2
(The solutions are the abscises of the intersection points of the graphs of y1 and y2,
meaning the values of x for which the two functions are equal).
6. Build a VI that rotates a segment around one of its fixed end. On the FP are given the
segment length, the coordinates of the fixed end, the number of points of the free end
trajectory, the rotation speed and the rotation sense.
7. The same problem as above, but the segment rotates around its middle.