Question

USING MATLAB (A) Use the rand command to generate “X” of size [10000 1] and the...

USING MATLAB

(A) Use the rand command to generate “X” of size [10000 1] and the command histogram to plot the probability distribution of “X” along with axis labels and a title that includes the mean and variance for “X”. (B) Use a while loop and the rand command to generate “X1”, also of size [10000 1] but with each element of “X1” being the mean of 2 “samples” generated using rand, i.e. a “sample size” of 2 separate numbers generated using rand that are then averaged. This is repeated until “X1” is of size [10000 1].

Homework Answers

Answer #1

% Matlab script to create random vectors and plot probability distribution
% A

% generate X of size [10000 1]
X = rand(10000, 1);
% histogram to plot the probability distribution of "X"
histogram(X);
% specify the X and Y labels
xlabel('X');
ylabel('Y');
% specify the title containing the mean and variance of X
txt = sprintf('Mean: %f Variance: %f',mean(X), var(X));
title(txt);

%B
% create X1 of size [10000 1]
X1 = zeros(10000,1);
i=1; % set i to 1
% loop over X1 vector, generating elements for X1
while(i <= length(X1))
samples = rand(2,1); % generate a sample size of 2 using rand
X1(i) = mean(samples); % set ith element of X1 to average of the samples
i = i + 1;
end

%end of script

  

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Assignments Generate and plot the signal x1(t) = 1+ sin (4pt), for t ranging from -1...
Assignments Generate and plot the signal x1(t) = 1+ sin (4pt), for t ranging from -1 to 1 in 0.001 increments. Use proper axes labels with title. Generate and plot the function x2(t) = sin (30pt), for t ranging from -1 to 1 in 0.001 increments. Use proper axes labels with title. Generate and plot the combination function x3(t) = x1(t)*x2(t) as above. Use proper axes labels with title. Generate and plot the sum of two cosine waves   v1(t) =...
SIGNALS AND SYSTEMS Experiment 1    Signal Generation Date: January 1-8, 2018 The purpose of this...
SIGNALS AND SYSTEMS Experiment 1    Signal Generation Date: January 1-8, 2018 The purpose of this laboratory is to familiarize you with the basic commands in MATLAB for signal generation and verify the generated signal. Objectives 1.Learn basic MATLAB commands and syntax, including help system. 2.Use MATLAB ( from Citrix) to generate and plot different signals. Assignments Generate and plot the signal x1(t) = 1+ sin (4pt), for t ranging from -1 to 1 in 0.001 increments. Use proper axes...
USING MATLAB Code for pseudo Random Input N M=0 For i=1 to N X=rand# Y=rand# If...
USING MATLAB Code for pseudo Random Input N M=0 For i=1 to N X=rand# Y=rand# If X^2+ y^2 <= 1, then M=M+1 End the loop Print M/N (This is the probability) Print M/N (this is approximately = Py
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
1. Now generate y array using the function file my_func for the x array varying from...
1. Now generate y array using the function file my_func for the x array varying from 0 to 4 with an increment of 0.2. Generate x and y arrays without using any loop statement and do not print these arrays. 2. Off of question 1. Using MATLAB plot routine, plot y-array against the x-array generated in question 1. On this plot show grid lines, label the axes as x and y, and write the text ‘y=f(x)’ next to the plotted...
Write as a MatLab script For X=0 ~ 2π with intervals of π/100 use the following...
Write as a MatLab script For X=0 ~ 2π with intervals of π/100 use the following equations Y4=sin(X), Y5=sin(X-0.25), Y6=sin (X-1.5), Y7=sin(X-0.85), Y8=sin(X)sin(X+0.75) a. Plot Y4 and Y8 in the same plot using the hold on/off. Add title, labels. Plot them with different colors and line styles b. Plot Y5 × Y6 and Y8 in the same plot without using the hold on/off. Add title, labels. Plot them with different colors and line styles c. Plot one of the Y...
Show all steps please Using Matlab: Generate a random signal ‘x’ with a length of 8000...
Show all steps please Using Matlab: Generate a random signal ‘x’ with a length of 8000 and sampling rate of 8kHz. Plot a section of the signal In the time domain. Is it possible to observe significant trends in the time domain signal? Plot the magnitude of the DFT of segments of ‘x’ of different lengths. Use a decibel scale for the vertical axis. What do you observe as the segment length increases? Use the Matlab function ‘periodogram’ to obtain...
USING MATLAB: 1. Assume Y is an exponential random variable with rate parameter λ=2. (1) Generate...
USING MATLAB: 1. Assume Y is an exponential random variable with rate parameter λ=2. (1) Generate 1000 samples from this exponential distribution using inverse transform method (2) Compare the histogram of your samples with the true density of Y.
Let x be the vector 1:366. Use a nested for loop to estimate, for each value...
Let x be the vector 1:366. Use a nested for loop to estimate, for each value of the vector x[i] = i, the corresponding probability y[i] that there will be at least one common birthday if there are i people in a room (ignore leap years, as usual). Your for loop should create a vector y of the same size as x. Now use the plot command plot(x,y) to draw the graph. Use google to see how to add some...
Given the function y = e-0.4(x-3)^2. Compute the corresponding values of yh. Use the bar(xh,yh,.3) command...
Given the function y = e-0.4(x-3)^2. Compute the corresponding values of yh. Use the bar(xh,yh,.3) command to produce a bar graph. Next superimpose a continuous bell curve over it by taking one thousand samples of a new variable x again from 0 to 6 with the step size 6/999. Issue the hold on command and then use plot(x,y,’r’,’LineWidth’,2) command. All these commands are listed below. clear all; close all ; clc xh = 0:6/9:6; yh = exp(-0.4*(xh-3).^2); bar(xh,yh,0.3); hold on...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT