- Write a single instruction of Matlab that will take a vector x and change it to y such that any element of x that is greater than 1 is set to y=1; every element of x less than -1 is set to y=-1; and for elements of x between -1 and +1 we have y=x. Test it on x, where “t=linspace(0,10,400)” and “x=2*sin(pi*t)”, and plot both x and y on the same axes.
- Write a single instruction of Matlab that will plot a histogram of 12000 sums each of 10 pairs of 5-sided die rolls. For instructions on the histogram function type “help hist”, and an example might be “hist(randn(1,1000))” to see what the histogram of a bunch of Gaussian random variables looks like (a bell curve).
i just wrote this:
hist(sum(ceil(5*rand(12000,10)),2))