each value calculation for Mag Field

9 ビュー (過去 30 日間)
Offroad Jeep
Offroad Jeep 2015 年 5 月 25 日
回答済み: Walter Roberson 2015 年 5 月 26 日
Hi all, Kindly check this code. for each value of magnetic field there is value of angle alpha. I want to calculate zeeman energy and then for each angle alpha i want magnetization
clc
clear all
close all
nrows = 1;
si = (2.2 * 9.27e-24)* ones(nrows)
Si = sum(si); % Sum of rows for calculation of MAGNETIZATION
M_Si = sum(Si) % MAGNETIZATION ( Total magnetic moment of the array )
alpha = 30 * pi/180;% Initial angle of the magnetic moment with x-axis( No Field Applied )
beta = 20 * pi/180; % The angle at which Magnetic Field is applied to align all the moments
B_steps = 10;
applied_field = linspace(0,1,B_steps);
alpha_reduce = -linspace(alpha,beta,B_steps);
for i = 1:B_steps
alpha_trial = alpha + alpha_reduce(i)
zeeman(i) = - applied_field(i) * M_Si *cos(alpha_trial)
end
Magnetization = M_Si * cos(alpha_trial)
plot(applied_field,Magnetization,'*')
xlabel('Magnetization')
ylabel('applied_field')

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 26 日
At the end of your "for" loop, alpha_trial is going to be the last value it was in going through the loop, so it is going to be (alpha + alpha_reduce(B_steps)). Are you sure that is what you want?
Your code could be vectorized as
zeeman = -applied_field .* Msi .* cos(alpha + alpha_reduce);
But after your "for" loop, you do not use the value of zeeman(). So you might as well not calculate it at all.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by