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에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!