Please help to fix this error "First input argument must be a function handle".
Mostrar comentarios más antiguos
For single iteration(without loop), i'm getting the integral result (there is no error of function handle). But for iteration (using loop) I'm not getting the same.
%% Hallen's integral for wire antenna
clc;
clear all;
close all;
%syms z;
a = 0.00065; % inner radius
h = 0.005;
f = 1e9;
c = 3e8;
eo = 8.8541878176e-12;
uo = (4*pi)*10^ -7;
eta = 377;
er = 1;
w = 2*pi*f;
k = (w*sqrt(er))/c;
N = 9;
vo = 1;
dz = (2*h)/N;
U = zeros(1,N);
zn = -h+(dz/2);
C = zeros(N,1);
B = zeros(N,1);
for m = 1:N
zm(m) = (m - 0.5)*dz - h;
r(m) = @(z) sqrt(a^2 + (zm(m)-z).^2);
K(m) = @(r)(exp(-1i*k*r(m)))/(r(m))
U(m) = double((1/(4*pi))* integral(K(m),zn-(dz/2),zn+(dz/2),'ArrayValued',true));
end
It poping up error message "First input argument must be a function handle". please, help me to fix this .
Thank you for help!
5 comentarios
KALYAN ACHARJYA
el 13 de Feb. de 2020
See here
Adam
el 13 de Feb. de 2020
Do you need to be storing the function handles in an array every time round the loop given you use them on the next line? Do you intend to use them again later?
If so you need to save them in a cell array as you cannot save function handles in a regular array so I'm not sure why this line:
K(m) = @(r)(exp(-1i*k*r(m)))/(r(m))
wouldn't throw an error 2nd time round the loop before the one you mention, which I would assume is on the following line.
You can just put a breakpoint in or use 'Pause on Errors' from the 'Run' dropdown menu to investigate what is actuallu happening though.
sonu kumar
el 13 de Feb. de 2020
sonu kumar
el 13 de Feb. de 2020
sonu kumar
el 14 de Feb. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!