I am trying to find the triple integral of a function with limits defined for 'phi', 'z' and 'r'. On finding the value of the integral at any particular value say h=20 (h IS NOT GETTING INTEGRATED), I get a correct answer which matches with my experimental values. However, as soon as I vary (using linspace or colon) the value of h (h IS NOT GETTING INTEGRATED) I get an error saying "Matrix dimensions must agree". I have attached the code below for reference. Thank you
clc,clear
%magnetic field for an off axis point due to a thick solenoid in z-x plane
l=20; %length of the solenoid
r1 = 5; %inner radius
r2 = 10; %outer radius
u0 = 1.26*(10^-3); %permeability of free space
i = 3; %current in amps
N = 800; %number of turns
C=(u0*i*N)/(2*pi*10*l);
%location of x,y,z cooridnates of P
%rho = linspace(0,22,100);
rho = 0;
h=20:1:35;
Binz = @(r,z,phi)(r.*(r-(rho.*cos(phi))))./(((rho.^2) + (r.^2) + ((h-z).^2) – (2.*r.*rho.*cos(phi))).^(3/2));
Bz = C*integral3(Binz,r1,r2,0,20,0,2*pi); %magnetic field in z direction
plot (Bz,h);
Best Answer