Lab 1: Getting Started With Matlab I Generating Array Elements
Lab 1: Getting Started With Matlab I Generating Array Elements
b) Append the same array with 3 other elements all having values 1.
e) Display the 2nd and the 3rd element of the array at the command prompt.
g) Display the 2nd row 3rd column element of the array at the command prompt
h) Find the transpose of this matrix and display both the 3*3 matrices. Call it x3dc.
i) Find the sum of the array elements in x (the one -dimensional array created before).
What happens when I use the same command to the 3d array x3d.
II Getting used to functions to abs, sqrt and exp a) Find the square root of a positive number and store it in a variable called xsqrt. Obtain the positive number from the user.
b) Find the square root of a negative number and store it in a variable called xsqrt1. Obtain the number again from the user.
d) Find the abs value of xsqr1 and store that in the same variable Instruction:
Result:
III Create a simple sine function and Plot it a) Create a sine wave and assign it to a variable and plot it. Obtain the frequency of the sine wave for this question from the user.
b) Label your plot and label the axes. Sketch the result obtained on screen here.
f) What is the maximum frequency of the sine wave that you can plot for a given number of sample/period?
IV To get used to control functions a) Generate a random array of 100 elements. Call it x. Also generate another 100-element array containing values from 1 to 100 in steps of 1 and call it x1.
c) Set a counter that counts the number of odd elements in x and x1.
e) Generate a random sequence of binary digits using rand function and applying 0.5 as threshold value.
V To create functions and call and execute them a) Create a function that counts the number of multiples of 3 in an array. Call it mult3.