write a Program to model random motion of electron

조회 수: 12 (최근 30일)
ELUFISAN PAUL TOMILOLA
ELUFISAN PAUL TOMILOLA 2022년 3월 15일
댓글: ELUFISAN PAUL TOMILOLA 2022년 3월 16일
I am having difficulty in writing a program to model random motion of electron. The main problem here is that I want to assign each particle a random location in x-y plane with the extent of the silicon. The extent is 200nm by 100nm.
clc
clear all
LR = 200e-9; %Length of region
BR = 100e-9; %Breadth of region
numParticles = 1000;% no of particles
numSteps = 1;
x = zeros(numParticles, numSteps);
y = zeros(numParticles, numSteps);
xx = 0:0.2e-9:200e-9;
yy = 0:0.1e-9:100e-9;
h = meshgrid(xx,yy);

채택된 답변

Peter O
Peter O 2022년 3월 15일
You can use randi to place the 'electrons' at random points on the grid by picking the grid indexes at random. The distribution will be uniform and permit overlaps. If you need unique particle locations, you'll need to use randperm instead.
LR = 200e-9; %Length of region
BR = 100e-9; %Breadth of region
numParticles = 1000;% no of particles
numSteps = 1;
x = zeros(numParticles, numSteps);
y = zeros(numParticles, numSteps);
xx = 0:0.2e-9:200e-9;
yy = 0:0.1e-9:100e-9;
size_x = numel(xx);
size_y = numel(yy);
xindex_Particles = randi(size_x,[numParticles,1]);
yindex_Particles = randi(size_y,[numParticles,1]);
xy_Particles = [xx(xindex_Particles)', yy(yindex_Particles)'];
xy_Particles(1:5,:)
ans = 5×2
1.0e-06 * 0.0080 0.0845 0.0184 0.0847 0.0248 0.0197 0.1152 0.0781 0.0732 0.0055

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by