plot Bethe-Bloch equation

29 次查看(过去 30 天)
Jeroen
Jeroen 2012-2-27
Dear people,
For a project I have to plot the Bethe-Bloch equation. That is this equation: dedx = (-K*z^2*Z)/(A*beta2)*(0.5*log((2*me*1*10^9*beta2.*gamma2.*Tmax)/I^2)-beta2);
Every time i want to run the program it says the matrix dimension must agree. i do not know what i am doing wrong. I am trying this since the morning and I would like to move on. The only thing that chances is the eng. This has to run from 0 to 0.5 GeV.
clc; clear; z = 1; re = 2.817*10^-15; Z = 29; A = 63.546; Na = 6.022*10^23; mp = 0.93827231; %GeV eng = 0.001:0.001:0.5; %GeV gamma = (eng + mp)/mp; gamma2 = gamma.*gamma; beta = (1.0 - (1.0/(gamma2)')).^0.5; beta2 = beta.*beta; me = 0.51*10^-3; c = 3*10^8; I = 10*Z; K = 4*pi*Na*re^2*me*c^2;
Tmax = (2.0 * me*1e9*beta2'*gamma2)/(1.0 + (2.0*gamma*(me/mp) + (me/mp)^2)); Tmax = Tmax';
dedx = (-K*z^2*Z)/(A*beta2)*(0.5*log((2*me*1*10^9*beta2.*gamma2.*Tmax)/I^2)-beta2);
figure; plot(eng,dedx);
  3 个评论
Jeroen
Jeroen 2012-2-27
clc;
clear;
z = 1;
re = 2.817*10^-15;
Z = 29; A = 63.546;
Na = 6.022*10^23;
mp = 0.93827231; %GeV
eng = 0.001:0.001:0.5; %GeV
gamma = (eng + mp)/mp;
gamma2 = gamma.*gamma;
beta = (1.0 - (1.0/(gamma2)')).^0.5;
beta2 = beta.*beta;
me = 0.51*10^-3;
c = 3*10^8;
I = 10*Z;
K = 4*pi*Na*re^2*me*c^2;
Tmax = (2.0 * me*1e9*beta2'*gamma2)/(1.0 + (2.0*gamma*(me/mp) + (me/mp)^2));
Tmax = Tmax';
dedx = (-K*z^2*Z)/(A*beta2)*(0.5*log((2*me*1*10^9*beta2.*gamma2.*Tmax)/I^2)-beta2);
figure;
plot(eng,dedx);
Kunal Kumar
Kunal Kumar 2021-5-25
Jeroen, I am having this same problem. Can you help me with the code. I tried running your code but it shows error. Can you share the code that ran on MATLAB.

请先登录,再进行评论。

回答(1 个)

Grzegorz Knor
Grzegorz Knor 2012-2-27
Use .* (the element-by-element product) operator for array multiplication.
  3 个评论
Grzegorz Knor
Grzegorz Knor 2012-2-27
The same for division: ./
I've checked, and it works.
Jeroen
Jeroen 2012-2-27
Okay thank you. It works now!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by