Question: Molecular Diffusion (Submit answers in a live notebook) Consider the following MATLAB code for the simulation of molecular diffusion. Answer the questions below, noting the

Molecular Diffusion (Submit answers in a live notebook)

Consider the following MATLAB code for the simulation of molecular diffusion. Answer the questions below, noting the locations for these questions in the code.

% number of molecules

n = 1000;

% initial coordinates of molecules

x = 100*rand(n, 1);

y = 100*rand(n, 1);

% temperature (arbitrary units)

T = 1;

% (location for question a)

t = length(time);

% variables for storing output of simulation

XT = zeros(n, t);

YT = zeros(n, t);

% loop over time

for i = 1:t

% (location for question b)

% (location for question c)

end

% (location for question d)

Write a single MATLAB expression that defines a vector named time, such that: time(1) must equal 0 time(end) must equal 10 all successive elements of time must increase in 0.1 increments

Assume that the molecules diffuse (move randomly) and that the magnitude of this diffusion is solely proportional to the temperature T. Use this knowledge to write an expression which simulates the diffusion for all molecules at a specific time point t.

Write expressions that store the horizontal and vertical coordinates of all molecules at a single time point, in variables XT and YT.

Make the following plots:

a plot of the x coordinate of molecule 5 as a function of time.

a plot of the y coordinate of molecule 5 as a function of time.

a plot of the relationship between the x and y coordinates of molecule 5 over the full period of the simulation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!