Using Matlab please answer problem 1, part a . Please explain for part a.
1. MATLAB Script Files
(a) Experiment with vectors in MATLAB. Try the following:
iset = -3 :11;
iset
cos( pi*iset/4)
Explain how the last example computes the different values of cosine without a loop.
iset = -3:11 gives a vector starting from -3 to 11 with step sie of 1
iset = -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11
cos(pi*iset/4)
to explain this
first iset/4 gives a vector of same length iset but each element will be divided by 4
pi*(iset/4) multiples each element of iset/4 with pi
cos(pi*iset/4) computes cos of each element of pi*iset/4 and produces the result
here pi*iset/4 is a vector
evaluating a function with vector gives a vector
cos(pi*iset/4) =
ans = Columns 1 through 6: -7.0711e-01 6.1232e-17 7.0711e-01 1.0000e+00 7.0711e-01 6.1232e-17 Columns 7 through 12: -7.0711e-01 -1.0000e+00 -7.0711e-01 -1.8370e-16 7.0711e-01 1.0000e+00 Columns 13 through 15: 7.0711e-01 3.0616e-16 -7.0711e-01
Get Answers For Free
Most questions answered within 1 hours.