Unrecognized function or variable 'quad8'

Greetings,
Currenlty working on a project for a radar class I am taking and I keep getting an error for Unrecognized function or variable 'quad8'. As far as I know quad is supposed to numerciallly evaluate an integral. I tried using quall and intgeral instead but keep getting an error. I am basically troubleshooting this entire code which is lengthy and I can certainly use some advice. The end result is a Power Spectral Density plot and a isodop footprint plot which is describing a radar travelling horizontally with a narrow beam antenna squinted at 45 degrees.I attached pics of what plots should look like. I am including the code here.Thank you in advance for any help you may offer!
clear all;
close;
format long;
global r;
%
%Setup of the parameters
%
u=7.5e+3; %speed of the plane
alpha0=2.5*pi/180; %beam depth in radians
alpha_lim=1.5*alpha0; %limit angle for integration
phi=45*pi/180; %squinted angkle in radiians
theta=30*pi/180; %vertial plotting anglein radians
%Finding the limit in the integration
%path in terms of relative Doppler frequency
%
c = cos(alpha_lim);
s = sin(alpha_lim);
fu = (8*c*c-7)/(-2*sqrt(14)*s+2*sqrt(2)*c)
fl = (8*c*c-7)/(2*sqrt(14)*s+2*sqrt(2)*c)
%
% Computing the power spectral density(psd)
%
fd = linspace(fu,fl,502); % rrelative Doppler frequency
fr = 1./fd; % fr parameter
Num = length(fr);
psd = zeros(1,Num-2); % We exclude the boundary points
% in the psd
footprint_u = zeros(1,Num-2);
footprint_l = zeros(1,Num-2);
footprint_f = zeros(1,Num-2);
for n = 2:Num-1,
r = fr(n);
t1 = sqrt(r*r-1);
t2 = sqrt(7*(r*r-1)-(1-2*sqrt(2)*c*r)^2);
t3 = 1+t1-2*sqrt(2)*c*r;
su = (-sqrt(6)*t1-t2)/t3;
sl = (-sqrt(6)*t1+t2)/t3;
uu = log(su);
ul = log(sl);
footprint_u(n-1) = uu;
footprint_l(n-1) = ul;
footprint_f(n-1) = r;
psd(n-1) = quad8('f_int',ul,uu)/(sqrt(1-1/r/r))^3;
end
psd= psd/max(psd);
fd_plot = fd(2:Num-1);
plot(fd_plot,psd);
%semilogy(fd_plot,psd);
hold on
x_fl=[fd(1) fd(1)];
y_fl=[0 1];
plot(x_fl,y_fl,'k')
%semilogy(x_fl,y_fl,'k')
x_fu=[fd(Num) fd(Num)];
y_fu=[0 1];
plot(x_fu,y_fu,'k')
%semilogy(x_fu,y_fu,'k')
title('Fading Spectrum')
xlabel('f_{D}/f_{D_{0}}')
ylabel('PSD/PSD_{0}')
text(0.281,.5,'lowest f_{d}/f_{d_{0}}=0.292');
text(0.385,.5,'highest f_{d}/f_{d_{0}}=0.414');
%
% generating the Limit Isodops and
% The footprint
%
figure(2)
u_hyp=linspace(0,1,100);
x_hyp_low=cosh(u_hyp)./(sqrt((1/fu)^2-1));
y_hyp_low_sinh(u_hyp);
plot(x_hyp_low,y_hyp_low,'k--')
hold on;
x_hyp_up=cosh(u_hyp)./(sqrt((1/fl)^2-1));
y_hyp_up=sinh(u_hyp);
plot(x_hyp_up,y_hyp_up,'k--')
% The footprint
% Those point belong to thte isodops
% and for those points u=uu or ul
%
u_footprint = zeros(1,2*Num-4);
f_footprint = zeros(1,2*Num-4);
for n = 1:Num-2,
u_footprint1(n)=footprint_u(n);
u_footprint2(n)=footprint_1(n);
f_footprint1(n)=footprint_f(n);
f_footprint2(n)=footprint_f(n);
end
x_footprint1=cosh(u_footprint1)./(sqrt((f_footprint1).^2-1));
y_footprint1=sinh(u_footprint1);
plot(x_footprint1,y_footprint1);
x_footprint2=cosh(u_footprint2)./(sqrt((f_footprint2).^2-1));
y_footprint2=sinh(u_footprint2);
plot(x_footprint2,y_footprint2);
axis equal;
set(gca, 'xlim', [0 0.8], 'ylim', [0 0.8])
title('Footprint')
xlabel('X=x/h')
ylabel('Y=y/h')
grid on
text(0.25, 0.1, 'f_{d}/f_{d}_{0}=0.292')
text(0.5, 0.7, 'f_{d}/f_{d}_{0}=0.414')
%
% This is the integrand for the psd
%
function y = f_int(x)
global r
s = exp(x);
rterm = sqrt(r*r-1);
alpha0 = 2.5*pi/180;
alpha = acos(((1+rterm)*s.*s+2*sqrt(6)*rterm*s+(1-rterm))./ ...
(2*sqrt(2)*r*(s.*s+1)));
y = (cosh(x).^2-1/r/r).*exp(-2*alpha.*alpha/alpha0/alpha0);
end

 Accepted Answer

Thank you tremendously for all your guidance!!

1 Comment

Voss
Voss on 13 Feb 2022
Edited: Voss on 13 Feb 2022
No problem! How about you do me a favor and unaccept your answer and accept mine? I appreciate it!

Sign in to comment.

More Answers (1)

Voss
Voss on 12 Feb 2022
Edited: Voss on 12 Feb 2022
As mentioned in the answer here (with plenty of reference links in it):
quad8() has been removed and replaced by quadl(), which was then replaced by integral().
Changing quad8 to integral and changing the first argument to a function handle - and fixing a couple of typos - seems to have gotten the code to run:
clear all;
close;
format long;
global r;
%
%Setup of the parameters
%
u=7.5e+3; %speed of the plane
alpha0=2.5*pi/180; %beam depth in radians
alpha_lim=1.5*alpha0; %limit angle for integration
phi=45*pi/180; %squinted angkle in radiians
theta=30*pi/180; %vertial plotting anglein radians
%Finding the limit in the integration
%path in terms of relative Doppler frequency
%
c = cos(alpha_lim);
s = sin(alpha_lim);
fu = (8*c*c-7)/(-2*sqrt(14)*s+2*sqrt(2)*c)
fu =
0.413975431045285
fl = (8*c*c-7)/(2*sqrt(14)*s+2*sqrt(2)*c)
fl =
0.291617380244238
%
% Computing the power spectral density(psd)
%
fd = linspace(fu,fl,502); % rrelative Doppler frequency
fr = 1./fd; % fr parameter
Num = length(fr);
psd = zeros(1,Num-2); % We exclude the boundary points
% in the psd
footprint_u = zeros(1,Num-2);
footprint_l = zeros(1,Num-2);
footprint_f = zeros(1,Num-2);
for n = 2:Num-1,
r = fr(n);
t1 = sqrt(r*r-1);
t2 = sqrt(7*(r*r-1)-(1-2*sqrt(2)*c*r)^2);
t3 = 1+t1-2*sqrt(2)*c*r;
su = (-sqrt(6)*t1-t2)/t3;
sl = (-sqrt(6)*t1+t2)/t3;
uu = log(su);
ul = log(sl);
footprint_u(n-1) = uu;
footprint_l(n-1) = ul;
footprint_f(n-1) = r;
% psd(n-1) = quad8('f_int',ul,uu)/(sqrt(1-1/r/r))^3;
psd(n-1) = integral(@f_int,ul,uu)/(sqrt(1-1/r/r))^3;
end
psd= psd/max(psd);
fd_plot = fd(2:Num-1);
plot(fd_plot,psd);
%semilogy(fd_plot,psd);
hold on
x_fl=[fd(1) fd(1)];
y_fl=[0 1];
plot(x_fl,y_fl,'k')
%semilogy(x_fl,y_fl,'k')
x_fu=[fd(Num) fd(Num)];
y_fu=[0 1];
plot(x_fu,y_fu,'k')
%semilogy(x_fu,y_fu,'k')
title('Fading Spectrum')
xlabel('f_{D}/f_{D_{0}}')
ylabel('PSD/PSD_{0}')
text(0.281,.5,'lowest f_{d}/f_{d_{0}}=0.292');
text(0.385,.5,'highest f_{d}/f_{d_{0}}=0.414');
%
% generating the Limit Isodops and
% The footprint
%
figure(2)
u_hyp=linspace(0,1,100);
x_hyp_low=cosh(u_hyp)./(sqrt((1/fu)^2-1));
% y_hyp_low_sinh(u_hyp);
y_hyp_low=sinh(u_hyp); % possible typo corrected
plot(x_hyp_low,y_hyp_low,'k--')
hold on;
x_hyp_up=cosh(u_hyp)./(sqrt((1/fl)^2-1));
y_hyp_up=sinh(u_hyp);
plot(x_hyp_up,y_hyp_up,'k--')
% The footprint
% Those point belong to thte isodops
% and for those points u=uu or ul
%
u_footprint = zeros(1,2*Num-4);
f_footprint = zeros(1,2*Num-4);
for n = 1:Num-2,
u_footprint1(n)=footprint_u(n);
% u_footprint2(n)=footprint_1(n);
u_footprint2(n)=footprint_l(n); % possible typo corrected
f_footprint1(n)=footprint_f(n);
f_footprint2(n)=footprint_f(n);
end
x_footprint1=cosh(u_footprint1)./(sqrt((f_footprint1).^2-1));
y_footprint1=sinh(u_footprint1);
plot(x_footprint1,y_footprint1);
x_footprint2=cosh(u_footprint2)./(sqrt((f_footprint2).^2-1));
y_footprint2=sinh(u_footprint2);
plot(x_footprint2,y_footprint2);
axis equal;
set(gca, 'xlim', [0 0.8], 'ylim', [0 0.8])
title('Footprint')
xlabel('X=x/h')
ylabel('Y=y/h')
grid on
text(0.25, 0.1, 'f_{d}/f_{d}_{0}=0.292')
text(0.5, 0.7, 'f_{d}/f_{d}_{0}=0.414')
%
% This is the integrand for the psd
%
function y = f_int(x)
global r
s = exp(x);
rterm = sqrt(r*r-1);
alpha0 = 2.5*pi/180;
alpha = acos(((1+rterm)*s.*s+2*sqrt(6)*rterm*s+(1-rterm))./ ...
(2*sqrt(2)*r*(s.*s+1)));
y = (cosh(x).^2-1/r/r).*exp(-2*alpha.*alpha/alpha0/alpha0);
end

8 Comments

I tried running it but I am getting an error message that says
Attempt to execute SCRIPT integral as a function:
Error in Untitled (line 47)
psd(n-1) = integral(@f_int,ul,uu)/(sqrt(1-1/r/r))^3;
I think what is going on is that you have the integral being called as a script before being called as a function.. I am currenlty sorting out info on mathworks website including renaming the script. I tried putting which <integral> -all but either I am putting that in the wrong location, or that is not the answer. Any suggestions on how I can have integral to be called as a function and not a script?
What is the name of your m-file? Do you have an "integral.m" file? What does this say in the command window:
which -all integral
Gosh, quad8 was a long time ago!
@Jose Iglesias: As you can see, the code runs here and generates those beautiful plots. So most likely the problem is that you have a script called integral.m somewhere on your path taking precedence over the built-in MATLAB function integral.m. Please show the output of which -all integral and/or which integral -all (no <> around integral) as @Image Analyst requested.
@Walter Roberson: Yeah, I think quad8 was just a couple of years after Newton and Leibniz.
When I type in which -all integral it says this
C:\Users\macaw\OneDrive - Arizona State University\Documents\MATLAB\Examples\R2020a\antenna\atx_pattern_custom\integral.m
C:\Program Files\MATLAB\R2020a\toolbox\matlab\funfun\integral.m
Thanks. Try renaming or removing the file at:
C:\Users\macaw\OneDrive - Arizona State University\Documents\MATLAB\Examples\R2020a\antenna\atx_pattern_custom\integral.m
Then run the code again and see if it works.
You could also edit your path so it doesn't include that directory.
Thank you for all your help. I renamed the file and it works.

Sign in to comment.

Products

Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!