each value calculation for Mag Field
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Offroad Jeep
el 25 de Mayo de 2015
Respondida: Walter Roberson
el 26 de Mayo de 2015
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')
0 comentarios
Respuesta aceptada
Walter Roberson
el 26 de Mayo de 2015
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Computational Fluid Dynamics (CFD) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!