Question

We will be using Matlab as the software tool for this lab project. 1.Explore and become...

We will be using Matlab as the software tool for this lab project.

1.Explore and become familiar with the random number generators in Matlab such as “rand”,

“randn”, and “randi” (in fact all software tools can only generate pseudo-random numbers). Notice that to randomize the generators the use of “rng” function is encouraged as the previous techniques are discouraged.

2. “Random walk” is one of the primary and relative simple random processes in which the process

starts from a neutral position (position = 0) and by tossing a fair coin the process (the walker) moves

either one step forward (step = +1, with probability 0.5) or one step backward (step = -1, with probability 0.5). The goal is to observe the process as it progresses for large number of trials, say 100 or 1000.

Write the required Matlab script to simulate a single random walk process for 100 steps. The following delineates the required script. This must include an appropriate plot with marker.

Position = 0;

for n = 1: Nstep

% generate the random step of +1 or -1....

end

% Use “cumsum” function to complete Position from the generated steps.

% Plot the single random walk process with marker and appropriate labels.

Include your script and the plot in your report.

3.Repeat the random walk process of previous section for an ensemble of say 5 simultaneous processes. Plot the ensemble of the processes on the same figure. Change the graph color of each process for better representation. Ask the user to enter the number of processes to be simulated. Include your script and the plot in your report. Notice that you can create a matrix of the number of processes (Nwalks) to be its columns and the number of steps (Nsteps) to be its rows and plot the matrix versus the steps generated as:

n = 1:Nsteps

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Nstep=100;
processes=input('Enter number of processes: ');
position=zeros(Nstep+1,processes);
for j=1:processes
for i=1:Nstep
A=randi(2);
if A==1
position(i+1,j)=1;
else
position(i+1,j)=-1;
end
end
end
position=cumsum(position,1);
plot(0:Nstep,position)
xlabel('Steps')
ylabel('Position')

反Editor-CAUsersWeibhavDocumentsiMATLAB21RandomWalk_cumsum.m Command Windovw EDITOR PUBLISH RandomWalk cumsum Enter number of processes: 5 Find Files * EDIT Breakpoints Run Run and New Open Save La compare ▼ I Go To▼ Print Find RUN FILE RandomWalk cumsum.m X+ 1 -Nstep-100: 2processes-input Enter number of processes Figure 1 position-zeros (Nstep+1, processes) j=1 :processes for i-l:Nste 4 for - File Edit View Insert Tools Desktop Window Help A-randi (2) if A--1 position (i+l,5)-1 15 else 10 position (1+1, j)=-1; end 10 end end 13- 14 -position cumsum (position,1) 15-plot (0:Nstep, position) 16-xlabelSteps) 17-ylabel1Position) 18 -5 -10 -15 70 80 90 100 0 10 20 30 40 50 60 Steps

Add a comment
Know the answer?
Add Answer to:
We will be using Matlab as the software tool for this lab project. 1.Explore and become...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals clear all c...

    LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals clear all close al1: Generate signals for testing the LMS Algorithm 1000 Fs Sampling frequency Sample time 1/Fs 10000: = L Length of signal S Time vector (0:L-1) *T ; Sum of a 50 Hz sinusoid and a 120 Hz sinusoid 0.7 sin (2*pi*50*t); inuside X d+ 10 randn (size (t)); Sinusoids 5O0000000L plus noise fiqure (1) plot (Fs*t (1:150),x (1:1500)) title('Signal Corrupted with...

  • LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals...

    LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals clear all close al1: Generate signals for testing the LMS Algorithm 1000 Fs Sampling frequency Sample time 1/Fs 10000: = L Length of signal S Time vector (0:L-1) *T ; Sum of a 50 Hz sinusoid and a 120 Hz sinusoid 0.7 sin (2*pi*50*t); inuside X d+ 10 randn (size (t)); Sinusoids 5O0000000L plus noise fiqure (1) plot (Fs*t (1:150),x (1:1500)) title('Signal Corrupted with...

  • His own report It is a personalized project; each student has to submit Exercise # 1 Collect and ...

    his own report It is a personalized project; each student has to submit Exercise # 1 Collect and Comment on the variability of three recent data sets describing similar processes (could be prices of three items over the last month, demographic information related to 3 countries over last year, etc.) Exercise # 2: Plot the probability mass function (PMF) and the cumulative distribution function (CDF) of 3 random variables following (1) binomial distribution (p.nl, (2) a geometric distribution [p), and...

  • Please can you solve it using MATLAB. (1) Generate random signals [n] and hn, each of...

    Please can you solve it using MATLAB. (1) Generate random signals [n] and hn, each of length N, and measure the time it takes to compute the linear convolution of r[n using the linear convolution definition and using the FFT method . Plot a graph of the results for N 104 to 10 in steps of 10. (2) Consider the signal x[n]-cos(0.3n),。£11S 100. Generate a plot of: ·The magnitude and phase of the DTFT of x[n] for 0 2π The...

  • Program from problem 1: (Using MATLAB) % Sampling frequency and sampling period fs = 10000; ts...

    Program from problem 1: (Using MATLAB) % Sampling frequency and sampling period fs = 10000; ts = 1/fs; % Number of samples, assume 1000 samples l = 1000; t = 0:1:l-1; t = t.*ts; % Convert the sample index into time for generation and plotting of signal % Frequency and amplitude of the sensor f1 = 110; a1 = 1.0; % Frequency and amplitude of the power grid noise f2 = 60; a2 = 0.7; % Generating the sinusoidal waves...

  • For this project, each part will be in its oun matlab script. You will be uploading a total 3 m f...

    For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...

  • 4. Matlab Solvers: A Case Study in Mechanics Suppose we have two objects orbiting in space,...

    4. Matlab Solvers: A Case Study in Mechanics Suppose we have two objects orbiting in space, with masses 1 - and , rotating around each other. For example, think of the earth and the moon, where the moon moves around the earth at distance 1. (Of course, here both the masses and the distance are normalized.) A third object, which is relatively much smaller and does not affect the motion of the first two, is also orbiting in space. Think...

  • This project is meant to give you experience writing linked lists and graphs. As such, you...

    This project is meant to give you experience writing linked lists and graphs. As such, you are not permitted to use arrays or any data structure library. You may, however, make use of code presented in class and posted to Blackboard. Objective Your goal for this project is to take a block of text, analyze it, and produce random sentences in the style of the original text. For example, your program, given Wizard of Oz, might produce: how quite lion...

  • C++. Need some help getting started. We will also have the following two functions: 1. A...

    C++. Need some help getting started. We will also have the following two functions: 1. A mutate function that randomly modifies a chromosome. 2. A crossover function that takes two chromosomes and splits each one at the same spot, then combines them together. Our genetic algorithm works by iterating over generations of chromosomes via the following process: 1. Generate random population. 2. Until we get an answer that is good enough, do the next steps in a loop: (a) Do...

  • Please help writing a well structured document using the below Agile Runbook - Our Overall Delivery Process How do we initiate a Project? Any project is a response to a pain point or desire expresse...

    Please help writing a well structured document using the below Agile Runbook - Our Overall Delivery Process How do we initiate a Project? Any project is a response to a pain point or desire expressed by either customers, internal stakeholders, employees, or regulatory authorities. In short, a project is a time bound and specific goal oriented task-system that is born out of an ask from any stakeholder. Project initiation is laying down a new project by defining its goals, objectives,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT