Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help me with this problem ( Matlab ) Create the following variables in your work

ID: 3871883 • Letter: H

Question

Help me with this problem ( Matlab )

Create the following variables in your workspace
(a) An array with 1000 elements, starting with 0, incrementing by /1000

(b) A 20 × 20 × 20 array full of numbers chosen from a Gaussian distribution with a mean of 0 and a standard deviation of .5.

(c) An array starting with 20, decrementing by 1 and ending with 1.

(d) Create a plot, using part (a) as the x-axis values, and the function sin(x) as the y-axis.

(e) Create a plot using the result from part (c) as the x-axis, and the 3rd row, 4th column, values 1 to 20 from part (b) for the y-axis. The squeeze command will be useful here (when I say this, it means to use the help or the internet and look up the squeeze command).

Explanation / Answer

for declaring an array in MATLAB, use the following commands

arr=0:pi/1000:0.99*pi;

This creates and array of 1000 elements starting from 0 with a difference pi/1000

For normal distribution

m = 5;
sd = 500;
x = m.*randn(20,20,20) + sd;

This generates a 20x20x20 array of guassian distribution samples

c.) a=20:-1:1;

d.) a=0:pi/1000:0.99*pi;

y=sin(a);

plot(a,y);

e.)

m = 5;
sd = 500;
x = m.*randn(20,20,20) + sd;

a=20:-1:1;

y=squeeze(x(3,4,1:20));

plot(a,y);