Hey,
I have this potential V=1/4*pi*epsilon*sqrt(((r1-r2)^2)+const.^2).
I solved for V =1/4*pi*epsilon*r using finite difference method but I'm unable to understand how to vary two variables for same axis. I have tried to do using different different loop for both parameters but can't find the solutions.
please help

 採用された回答

Image Analyst
Image Analyst 2021 年 5 月 16 日

0 投票

Pooja: You can use either meshgrid() or for loops. Below I show you both ways.
const = 2;
epsilon = 3;
maxR1 = 5.5;
maxR2 = 7.4;
% Define size of output matrix.
rows = 5;
columns = 4;
% Get x and y coordinates at each (y, x) location.
R1 = linspace(1, maxR1, columns); % x
R2 = linspace(1, maxR2, rows); % y
% Method 1 : vectorized using meshgrid()
[r1, r2] = meshgrid(R1, R2)
V = (1/4) * pi * epsilon * sqrt(((r1-r2).^2)+const ^ 2)
% Method 2 : for loops
V = zeros(rows, columns);
for col = 1 : columns
r1 = R1(col);
for row = 1 : rows
r2 = R2(row);
V(row, col) = (1/4) * pi * epsilon * sqrt(((r1-r2).^2)+const ^ 2);
end
end
V
fprintf('Done running %s.m ...\n', mfilename);

4 件のコメント

pooja sudha
pooja sudha 2021 年 5 月 17 日
Hey,
Actually I don't want this. let me explain again briefly.
Actually what I'm trying to do is, I have [-((hbar^2)/(2*m))(d^2/dr1^2 +d^2/dr2^2) +(1/4) * pi * epsilon * sqrt(((r1-r2).^2)+const ^ 2)] psi = E*psi equation.
and i am creating two matrices one for first part and another is for second part in left side of equation using finite difference method and will find eigen values & eigen vectors using this.
and here r1 is radial coordinate for one particle and r2 is radial coordinate for another particle. i want to plot eigen vectors.
pooja sudha
pooja sudha 2021 年 5 月 17 日
will it have four coordinates x1,y1 & x2, y2 and corresponding to this four for loops.
Image Analyst
Image Analyst 2021 年 5 月 18 日
No, why would it? I have only 2 for loops, not 4. I scan the values of r1 and r2 to get every possible combination. Then I compute the V for that combination of r1 and r2. V is not really an image, it's more like a table of values where the rows represent different r2 values and the columns represent different r1 values. There is not really an x and y like you'd think of in an image. There really are no "coordinates" in this situation. Like I said, it's more like a table or chart of values for the variety of r1 and r2 you might encounter.
If this is not what you want, then perhaps you need to provide a diagram showing what's going on.
pooja sudha
pooja sudha 2021 年 5 月 27 日
Hey Thankyou. It worked

サインインしてコメントする。

その他の回答 (1 件)

pooja sudha
pooja sudha 2021 年 5 月 19 日

0 投票

please find the attached code.
here i computed for I-dimension & for 1-particle by using the potential V=1/sqrt(r^2+constant^2) ,now same thing I'm trying to do for 2-particle by adding the coordinate for second particle in the potential like V=1/sqrt((r1-r2)^2+constant^2).
please help if you know about this.
Thank you

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by