Please help to fix this error "First input argument must be a function handle".
显示 更早的评论
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 个评论
KALYAN ACHARJYA
2020-2-13
See here
Adam
2020-2-13
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
2020-2-13
sonu kumar
2020-2-13
sonu kumar
2020-2-14
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!