필터 지우기
필터 지우기

each value calculation for Mag Field

조회 수: 2 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by