Can anyone solve the problem in my code that returns the error by ?
close allclear allclc%%
mu0 = 4*pi*1e-7; % Vs/Am
M0 = 1e3; % A/m
maxnum = 31;rho1_min = 0;rho1_max = 0.25;xlim = [-1, 1];ylim = xlim;zlim = xlim;x = linspace(min(xlim), max(xlim), maxnum);y = linspace(min(ylim), max(ylim), maxnum);z = linspace(min(zlim), max(zlim), maxnum);[Xg, Yg, Zg] = ndgrid(x, y, z);rho = sqrt(Xg.^2 + Yg.^2 + Zg.^2);phi = angle(Xg + 1i*Yg);theta = angle(Zg + 1i*sqrt(Xg.^2 + Yg.^2));%%RHO = sqrt(x.^2 + y.^2 + z.^2);THETA = linspace(0, pi, 31); % Trapz
PHI = linspace(0, 2*pi, 31); % Trapz%%
for i=1:numel(RHO) for j=1:numel(THETA) for k=1:numel(PHI) F_x{i,j,k} = (RHO(i)>= rho1_max) .* 2/3*M0*mu0 .* sin(theta) .* (RHO(i) .* (sin(THETA(j)) .* cos(theta) .* cos(PHI(k)-phi) - cos(THETA(j)) .* sin(theta)) ./ ... (RHO(i).^2 + rho1_max.^2 - 2.*RHO(i) .* rho1_max .* (sin(THETA(j)) .* sin(theta) .* cos(PHI(k)-phi) + cos(THETA(j)).* cos(theta))).^3/2) .* rho1_max.^2 .* sin(theta); B1x(i,j,k) = -trapz(PHI,trapz(THETA,F_x{i,j,k},2)) ; end end end
Best Answer