plot Bethe-Bloch equation

2 ビュー (過去 30 日間)
Jeroen
Jeroen 2012 年 2 月 27 日
コメント済み: Kunal Kumar 2021 年 5 月 25 日
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 Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by