I have the following code in matlab:
L = 10000;
Power = -100;
A = 10^0.5;
Fs = 25e6;
fc1 = 100;
fc2 = 1e3;
fc3 = 10e3;
fc4 = 100e3;
fc5 = 1e6;
a1 = 2*pi*fc1/Fs;
a2 = 2*pi*fc2/Fs;
a3 = 2*pi*fc3/Fs;
a4 = 2*pi*fc4/Fs;
a5 = 2*pi*fc5/Fs;
x = wgn(1,L,Power);
y1 = zeros(1,L);
y2 = zeros(1,L);
y3 = zeros(1,L);
y4 = zeros(1,L);
y5 = zeros(1,L);
y = zeros(1,L);
for i = 2:L,
y1(i) = (1-a1)*y1(i-1) + a1*x(i);
y2(i) = (1-a2)*y2(i-1) + a2*x(i)/A;
y3(i) = (1-a2)*y3(i-1) + a3*x(i)/A^2;
y4(i) = (1-a2)*y4(i-1) + a4*x(i)/A^3;
y5(i) = (1-a2)*y5(i-1) + a5*x(i)/A^4;
y(i) = y1(i) + y2(i) + y3(i) + y4(i) + y5(i);
end
fft1 = fft(y);
fft1 = fft1(1:length(y)/2+1);
psd1 = (1/(Fs*length(y)))*abs(fft1).^2;
psd1(2:end-1) = 2*psd1(2:end-1);
freq = 0:Fs/length(y):Fs/2;
figure(3);
semilogx(freq,10*log10(psd1))
grid on
Ts = 40e-9;
z = tf('z',Ts);
H1 = a1/(1-(1-a1)*z^-1);
H2 = (a2/A)/(1-(1-a2)*z^-1);
H3 = (a3/A^2)/(1-(1-a3)*z^-1);
H4 = (a4/A^3)/(1-(1-a4)*z^-1);
H5 = (a5/A^4)/(1-(1-a5)*z^-1);
H = (H1 + H2 + H3 + H4 + H5);
figure(5);
bode(H),grid
The intent of this code is to model flicker noise, which has 10dB/dec of slope in its power spectral density.
To model that there is a filter whose output is y(i) and input x(i) which is white guassian noise in this case. In the bode plot of the filter (labelled as figure 5) I can see that it has 10dB/dec of roll-off as I intended.
But when I check the output noise (y(i) in this case) power spectral density (labelled as figure 3) I am seeing 20dB/dec of roll-off.
Could someone please explain what I did wrong and why I am not able to get the 10dB roll-off in power spectral density?
Your bode plot uses a transfer function which is the sum of 5 similar subfilters, each using a coefficient ai. In your implementation, you should similarly have 5 subfilters with a regular structure. Howerver, while copying each line you have left some of the coefficients for y3, y4 and y5 to use a2. You should get your expected result by simply substituting the respective a3, a4 and a5 like so:
for i = 2:L,
y1(i) = (1-a1)*y1(i-1) + a1*x(i);
y2(i) = (1-a2)*y2(i-1) + a2*x(i)/A;
y3(i) = (1-a3)*y3(i-1) + a3*x(i)/A^2;
y4(i) = (1-a4)*y4(i-1) + a4*x(i)/A^3;
y5(i) = (1-a5)*y5(i-1) + a5*x(i)/A^4;
y(i) = y1(i) + y2(i) + y3(i) + y4(i) + y5(i);
end
Related
I'm trying to convert this Matlab code to Scilab, but I have some problems.
clear all; clc;
c0 = 0.8;
c1 = 1.3;
c11 = -6.1;
c12 = -0.6;
c2 = 1.7;
c22 = -1.7;
g = 0.05;
d = 0.01;
x1 = -9;
x2 = 8;
k = 1;
kmax = 100;
x1trace = [x1];
x2trace = [x2];
i = 2;
while k < kmax
gr1 = c1 + c12*x2 + 2*c11*x1;
x1 = x1 + g*gr1
x1trace(i) = x1;
x2trace(i) = x2;
i = i + 1;
gr2 = c2 + c12*x1 + 2*c22*x2;
x2 = x2 + g*gr2
x1trace(i) = x1;
x2trace(i) = x2;
i = i + 1;
if sqrt(gr1^2 + gr2^2) <= d;
break;
end
k = k + 1;
end
x = -10:0.1:10;
y = -10:0.1:10;
[X, Y] = meshgrid(x, y);
Z = c0 + c1*X + c2*Y + c12*X.*Y + c11*X.^2 + c22*Y.^2;
[C, h] = contour(X, Y, Z);
clabel(C, h);
hold on;
plot(x1trace, x2trace, '-');
text(x1trace(1) + 0.2, x2trace(1) + 0.5, 'M0');
text(x1 + 2, x2, ...
strvcat(['x1 = ' (num2str(x1))], ...
['x2 = ' (num2str(x2))], ...
['k = ' (num2str(k))]));
hold off;
I get an error for this line:
[C, h] = contour(X, Y, Z);
Wrong number of output arguments.
What should I change to fix it? Are there also any other errors in the code ?
You should have roughly the samed rendering with the following Scilab code. Scilab's contour needs (in the 4th argument) the number of level curves or the values themselves. In addition, you should use ndgrid instead of meshgrid:
clear clc;
c0 = 0.8;
c1 = 1.3;
c11 = -6.1;
c12 = -0.6;
c2 = 1.7;
c22 = -1.7;
g = 0.05;
d = 0.01;
x1 = -9;
x2 = 8;
k = 1;
kmax = 100;
x1trace = [x1];
x2trace = [x2];
i = 2;
while k < kmax
gr1 = c1 + c12*x2 + 2*c11*x1;
x1 = x1 + g*gr1
x1trace(i) = x1;
x2trace(i) = x2;
i = i + 1;
gr2 = c2 + c12*x1 + 2*c22*x2;
x2 = x2 + g*gr2
x1trace(i) = x1;
x2trace(i) = x2;
i = i + 1;
if sqrt(gr1^2 + gr2^2) <= d;
break;
end
k = k + 1;
end
x = -10:0.1:10;
y = -10:0.1:10;
[X, Y] = ndgrid(x, y);
Z = c0 + c1*X + c2*Y + c12*X.*Y + c11*X.^2 + c22*Y.^2;
clf
gcf.color_map=parulacolormap(8)($:-1:1,:)
contour(x, y, Z,0:-100:-700);
plot(x1trace, x2trace, '-');
xstring(x1trace(1) + 0.2, x2trace(1) + 0.5, 'M0');
xstring(x1 + 2, x2, ...
['x1 = '+string(x1)
'x2 = '+string(x2)
'k = '+string(k)]);
I have the following code in matlab:
L = 10000;
PN_30dB = -100; % dBc per Hz at 10k
f_offset = 5e6;
f_offset2 = 10e5;
F0 = 2.5e9;
A = 10^0.5;
Fs = 25e6;
fc1 = 100;
fc2 = 1e3;
fc3 = 10e3;
fc4 = 100e3;
fc5 = 1e6;
a1 = 2*pi*fc1/Fs;
a2 = 2*pi*fc2/Fs;
a3 = 2*pi*fc3/Fs;
a4 = 2*pi*fc4/Fs;
a5 = 2*pi*fc5/Fs;
sigma3 = (f_offset2/F0)*sqrt(2*10^(PN_30dB/10)/F0);
y1 = zeros(1,L);
y2 = zeros(1,L);
y3 = zeros(1,L);
y4 = zeros(1,L);
y5 = zeros(1,L);
y = zeros(1,L);
x = zeros(1,L);
for i = 2:L,
x(i) = sigma3*randn(1);
y1(i) = (1-a1)*y1(i-1) + a1*x(i);
y2(i) = (1-a2)*y2(i-1) + a2*x(i)/A;
y3(i) = (1-a3)*y3(i-1) + a3*x(i)/A^2;
y4(i) = (1-a4)*y4(i-1) + a4*x(i)/A^3;
y5(i) = (1-a5)*y5(i-1) + a5*x(i)/A^4;
y(i) = y1(i) + y2(i) + y3(i) + y4(i) + y5(i);
end
fft1 = fft(y);
fft1 = fft1(1:length(y)/2+1);
psd1 = (1/(F0*length(y)))*abs(fft1).^2;
psd1(2:end-1) = 2*psd1(2:end-1);
freq = 0:F0/length(y):F0/2;
figure(3);
semilogx(freq,10*log10(psd1))
grid on
acc = 0;
actual_timestamps_3 = zeros(1,L);
flicker = zeros(1,L);
for i = 1:L,
acc = acc + y(i);
actual_timestamps_3(i) = i/F0 + acc;
flicker(i) = acc;
end
fft1 = fft(2*pi*F0*flicker);
fft1 = fft1(1:length(flicker)/2+1);
psd1 = (1/(F0*length(flicker)))*abs(fft1).^2;
psd1(2:end-1) = 2*psd1(2:end-1);
freq = 0:F0/length(flicker):F0/2;
figure(4);
semilogx(freq,10*log10(psd1))
grid on
In this code, I am trying to create an output signal called flicker which should have a 30dB/dec roll-off of its power spectral density.
For that I am accumulating a signal called y(i) (in the second for loop) which has a 10dB/dec roll-off as can be seen in figure 3 inside the code. Since accumulation should add another 20db/dec, I am expecting the flicker signal to have a 30dB/dec roll off.
Signal y(i) is the output of a discrete time filter implemented in first for loop.
But I am not seeing the expected roll-off (30dB/dec) for the flicker signal (in figure 4). The plot shows only 20dB/dec for the flicker signal. Could someone please explain what I am doing wrong?
EDIT
Figure 4 in the code is shown below:
As you estimate the power spectral density with the FFT, you are looking at the data (flicker) which is effectively multiplied by a long rectangular window. This window introduces some spectral leakage, and unfortunately the decay of this spectral leakage for rectangular windows is less than 20dB/decade. The leakage from the stronger frequency components is thus masking the decay you are trying to observe.
To avoid this, you should multiply your signal by a different window function. There are plenty to experiment with (which offer different tradeoffs), but for illustration purposes you could use a blackman window with:
fft1 = fft(2*pi*F0*flicker .* blackman(length(flicker))');
My following code generates a graph with a looping variable for the x-axis. Specifically, eta_22 varies from 0 to 1, with loop iteration size of 0.01.
The code below the line is the source function file.
My question is: How can I generate a graph with eta_1 varying from 0 to 1, with loop iteration size of 0.01 as well? (I want a plot of AA on the y-axis, and eta_1, eta_2 varying from 0 to 1.)
My attempts: I have tried to create nested "for" loops, but the plot itself is looping. I have tried to put the plot line outside of the "for" loops as well, but that did not work.
Thanks for any help.
global Lambda mu mu_A mu_T beta tau eta_1 eta_2 lambda_T rho_1 rho_2 gamma
alpha = 100;
TIME = 365;
eta_22 = zeros(1,alpha);
AA = zeros(1,alpha);
for m = 1:1:alpha
eta_2 = m./alpha;
eta_22(m) = m./alpha;
Lambda = 531062;
mu = (1/70)/365;
mu_A = 0.25/365;
mu_T = 0.2/365;
beta = 0.187/365;
tau = 4/365;
lambda_T = 0.1;
rho_1 = 1/60;
rho_2 = (rho_1)./(270.*rho_1-1);
gamma = 1e-3;
eta_1 = 0;
S0 = 191564208;
T0 = 131533276;
H0 = 2405659;
C0 = 1805024;
C10 = 1000000;
C20 = 1000000;
CT10 = 500000;
CT20 = 500000;
y0 = [S0, T0, H0, C0, C10, C20, CT10, CT20];
[t,y] = ode45('SimplifiedEqns',[0:1:TIME],y0);
S = y(:,1);
T = y(:,2);
H = y(:,3);
C = y(:,4);
C1 = y(:,5);
C2 = y(:,6);
CT1 = y(:,7);
CT2 = y(:,8);
N = S + T + H + C + C1 + C2 + CT1 + CT2;
HIVinf1=[0:1:TIME];
HIVinf2=[beta.*(S+T).*(C1+C2)./N];
HIVinf=trapz(HIVinf1,HIVinf2);
AA(m) = HIVinf;
end
plot(100.*eta_22,AA./1000)
_____________________________________________________________________________________________________
function ydot = SimplifiedEqns(t,y)
global Lambda mu mu_A mu_T beta tau eta_1 eta_2 lambda_T rho_1 rho_2 gamma
S = y(1);
T = y(2);
H = y(3);
C = y(4);
C1 = y(5);
C2 = y(6);
CT1 = y(7);
CT2 = y(8);
N = S + T + H + C + C1 + C2 + CT1 + CT2;
ydot = zeros(8,1);
ydot(1)=Lambda-mu.*S-beta.*(H+C+C1+C2).*(S./N)-tau.*(T+C).*(S./N);
ydot(2)=tau.*(T+C).*(S./N)-beta.*(H+C+C1+C2).*(T./N)-(mu+mu_T).*T;
ydot(3)=beta.*(H+C+C1+C2).*(S./N)-tau.*(T+C).*(H./N)-(mu+mu_A).*H;
ydot(4)=beta.*(H+C+C1+C2).*(T./N)+tau.*(T+C).*(H./N)-(mu+mu_A+mu_T+lambda_T).*C;
ydot(5)=lambda_T.*C-(mu+mu_A+rho_1+eta_1).*C1;
ydot(6)=rho_1.*C1-(mu+mu_A+rho_2+eta_2).*C2;
ydot(7)=eta_1.*C1-(mu+rho_1+gamma).*CT1;
ydot(8)=eta_2.*C2-(mu+rho_2+gamma.*(rho_1)./(rho_1+rho_2)).*CT2+(rho_1).*CT1;
end
The simplest way:
eta_1=0:1/alpha:1;
eta_2=0:1/alpha:1;
lsize=length(eta_1) % I assume eta_1 and eta_2 are of the same size
for i=1:lsize
%Update your AA(i) here
end
plot(eta_1,AA,eta_2,AA)
While I am able to plot my FFT( fast fourier transform) plot(X,Y), however I am unable to plot my fit line f(x) along with my FFT. The equations was gathered from the curve fitting tool, I took the ten best fit and averaged the to come up with equation f(x).
what must I do for f(x) to be plotted with log(freq) and log(Pow)
code:
row=69;
col=69;
colormap gray
whitebg('black')
iterations=10^3;
Next=zeros(row,col);
laplacian=zeros(row,col);
critical=zeros(row,col);
B= zeros(row,col);
lums=zeros(1000);
flw=0.5;
u=0.1;
crit=5;
%bns=200;
bns=1000;
for k=1:iterations
B=B+(rand(row,col)-0.5);
Next=B;
rns=5.;
for i=1:row
for j=1:col
rfromns=(col+rns-j);
critical(i,j)=0;
if i<=2 left=row; else left=(i-1);end
if i==row right=1; else right=(i+1);end
if (j<=2) top=1; else top=(j-1);end
if (j==col) bottom=j; else bottom=(j+1);end
l=B(i,top)+B(left,j)+B(right,j)+B(i,bottom)+0.5*(B(left,top)+B(right,top)+B(left,bottom)+B(right,bottom));
l=l-6.*B(i,j);
laplacian(i,j)=l;
bfromns=bns/rfromns^3;
if (abs(l)/((abs(B(i,j))+bfromns)+0.01))>crit; critical(i,j)=1; end
%if abs(l)>crit; critical(i,j)=1; end
end
end
for j = 1:col
if (j==col) lum=0.;end
for i = 1:row
if (j>1) Next(i,j)=(1-flw)*B(i,j)+flw*B(i,j-1); end;
if (j==1) Next(i,j)=(1-flw)*B(i,j); end;
if (critical(i,j)==1)&& (j>1) Next(i,j)=B(i,j)*(1-flw-flw*u)+flw*B(i,j-1)+(flw*u)*B(i,j)/5.; end;
if i<2 left=row; else left=(i-1);end
if i==row right=1; else right=(i+1);end
if (j<=2) top=1; else top=(j-1);end
if (j==col) bottom=j; else bottom=(j+1);end
if (critical(left,j)==1) Next(i,j)=Next(i,j)+flw*u*B(left,j)/5.;end
if (critical(right,j)==1) Next(i,j)=Next(i,j)+flw*u*B(right,j)/5.;end
if (critical(i,top)==1) Next(i,j)=Next(i,j)+flw*u*B(i,top)/5.;end
if (critical(i,bottom)==1) Next(i,j)=Next(i,j)+flw*u*B(i,bottom)/5.;end
if (j==col) lum=lum+u*B(i,j)*B(i,j)+abs(laplacian(i,j)); end
end
end
lums(k)=lum;
B=Next;
%Matplot(B)
%if (k>00)
surf(B);
%plot(lums)
%view([0 90])
%pause(0.001)
%end
end
c=fft(lums(129:iterations));
pow=abs(c).^2;
pow=pow(2:(iterations-128)/2);
freq=(2:(iterations-128)/2);
X=log(freq);
Y=log(pow);
%x=length(X);
x=0.6:.1:6.;
%Linear model Poly2
a1 = -0.155;
a2 = 0.2154;
a3 = 15.1;
af(x) = a1*x.^2 + a2*x + a3;
%Linear model Poly3
b1 = 0.01805;
b2 = -0.3687;
b3 = 0.9874;
b4 = 14.29;
bf(x) = b1*x.^3 + b2*x.^2 + b3*x + b4;
%General model Power2
c1 = -0.09124;
c2 = 2.179;
c3 = 15.34;
cf(x) = c1*x.^c2+c3;
%General model Rat02
d1 = 727.3;
d2 = -3.447;
d3 = 51.6;
df(x) = (d1) / (x.^2 + d2*x + d3);
%General model Gauss1
e1 = 15.01;
e2 = 1.346;
e3 = 8.152;
ef(x) = e1*exp(-((x-e2)/e3).^2);
%General model Gauss2
w1 = 1.737;
w2 = 3.46;
w3 = 2.333;
w4 = 30.03;
w5 = -23.14;
w6 = 28.23;
wf(x) = w1*exp(-((x-w2)/w3).^2) + w4*exp(-((x-w5)/w6).^2);
%General model Sin1
g1 = 15.11;
g2 = 0.1526;
g3 = 1.428;
gf(x) = g1*sin(g2*x+g3);
%Linear model Poly4
h1 = 0.0179;
h2 = -0.252;
h3 = 1.047;
h4 = -1.97;
h5 = 16.23;
hf(x) = h1*x.^4 + h2*x.^3 + h3*x.^2 + h4*x + h5;
%General model Fourier1
m1 = 11.05;
m2 = 3.31;
m3 = 2.104;
m4 = 0.3644;
mf(x) = m1 + m2*cos(x*m4) + m3*sin(x*m4);
%Linear model
p1 = 0.815;
p2 = 0.1061;
p3 = 8.904;
pf(x) = p1*(sin(x-pi)) + p2*((x-10).^2) + p3;
f(x)=(af(x)+bf(x)+cf(x)+df(x)+ef(x)+wf(x)+gf(x)+hf(x)+mf(x)+pf(x))/10;
plot(X,Y)
plot(f(x))
Matlab/Octave therefore use the hold keyword.
If you want to plot several things on one graph, you start your program with hold on, then execute one or more plot command, and finalize with hold off.
Example:
hold on;
x = -10:0.1:10;
plot (x, sin (x));
plot (x, cos (x));
hold off;
Documentation: https://www.gnu.org/software/octave/doc/interpreter/Manipulation-of-Plot-Windows.html
As the documentation describes, plot will normally call the newplot command, that removes the previous plot result, with hold on; such behavior is prevented.
I would like to perform what follows:
where
The parameters shown in the latter figure can be obtained as follows:
%% Inizialization
time = 614.4; % Analysis Time
Uhub = 11;
HubHt = 90;
alpha = 0.14;
TI = 'A'; % Turbulent Intensity (A,B,C as in the IEC or Specific value)
N1 = 4096;
N2 = 32;
N3 = 32;
N = N1*N2*N3; % Total Number of Point
t = 0:(time/(N1-1)):time; % Sampled Time Vector
L1 = Uhub*time; % Box length along X
L2 = 150; % Box length along Y
L3 = 220; % Box length along Z
dx = L1/N1; % Grid Resolution along X-axis
dy = L2/N2; % Grid Resolution along Y-axis
dz = L3/N3; % Grid Resolution along Z-axis
V = L1*L2*L3; % Analysis Box Volume
gamma = 3.9; % Turbulent Eddies Distorsion Factor
c = 1.476;
b = 5.6;
if HubHt < 60
lambda1 = 0.7*HubHt;
else
lambda1 = 42;
end
L = 0.8*lambda1;
if isequal(TI,'A')
Iref = 0.16;
sigma1 = Iref*(0.75*Uhub + b);
elseif isequal(TI,'B')
Iref = 0.14;
sigma1 = Iref*(0.75*Uhub + b);
elseif isequal(TI,'C')
Iref = 0.12;
sigma1 = Iref*(0.75*Uhub + b);
else
sigma1 = str2num(TI)*Uhub/100;
end
sigma_iso = 0.55*sigma1;
sigma2 = 0.7*sigma1;
sigma3 = 0.5*sigma1;
%% Wave number vectors
ik1 = cat(2,(-N1/2:-1/2),(1/2:N1/2));
ik2 = -N2/2:N2/2-1;
ik3 = -N3/2:N3/2-1;
[x y z] = ndgrid(ik1,ik2,ik3);
k1 = reshape((2*pi*L/L1)*x,N1*N2*N3,1);
k2 = reshape((2*pi*L/L2)*y,N1*N2*N3,1);
k3 = reshape((2*pi*L/L3)*z,N1*N2*N3,1);
k = sqrt(k1.^2 + k2.^2 + k3.^2);
%% Calculation of beta by means of the Energy Spectrum Integration
E = #(k) (1.453*k.^4)./((1 + k.^2).^(17/6));
%//Independent integration on segments
Local_int = arrayfun(#(i)quad(E,i-1,i), 2:(N1*N2*N3));
%//integral additivity + cumulative removal of queues
E_int = 1.5 - [0 fliplr(cumsum(fliplr(Local_int)))]; %//To remove queues
E_int = reshape(E_int,N,1);
S = k.*sqrt(E_int);
beta = (c*gamma)./S;
%% Help Parameters
k30 = k3 + beta.*k1;
k0 = sqrt(k1.^2 + k2.^2 + k30.^2);
C1 = (beta.*k1.^2.*(k1.^2 + k2.^2 - k3.*k30))./(k.^2.*(k1.^2 + k2.^2));
C2 = (k2.*k0.^2./((k1.^2 + k2.^2).^(3/2))).*atan2((beta.*k1.*sqrt(k1.^2 + k2.^2)),(k0.^2 - k30.*k1.*beta));
xhsi1 = C1 - (k2./k1).*C2;
xhsi2 = (k2./k1).*C1 + C2;
E_k0 = (1.453*k0.^4)./((1 + k0.^2).^(17/6));
For instance, typing in
phi_33 = #(k2,k3) (E_k0./(4*pi.*k.^4)).*((k1.^2 + k2.^2));
F_33 = arrayfun(#(i) dblquad(phi_33,k3(i),k3(i+1),k2(i),k2(i+1)), 1:((N1*N2*N3)-1));
Matlab retrieves the following error msg:
Error using +
Matrix dimensions must agree.
Error in #(k2,k3)(E_k0./(4*pi.*k.^4)).*((k1.^2+k2.^2))
Do you have a clue how to overcome this issue?
I really look forward to hearing from you.
Best regards,
FPE
The error is easily explained:
First you define E_k0 then you try to call Ek0.
phi_11 = #(k1,k2,k3) (E_k0./4*pi.*kabs.^4).*(k0abs.^2 - k1.^2 - 2*k1.*k03.*xhsi1 + (k1.^2 + k2.^2).*xhsi1.^2);
I solved it this way:
Code a function for each of the PHI elements, such as (for PHI11)
function phi_11 = phi_11_new(k1,k2,k3,beta,i)
k = sqrt(k1(i).^2 + k2.^2 + k3.^2);
k30 = k3 + beta(i).*k1(i);
k0 = sqrt(k1(i).^2 + k2.^2 + k30.^2);
E_k0 = 1.453.*k0.^4./((1 + k0.^2).^(17/6));
C1 = (beta(i).k1(i).^2).(k1(i).^2 + k2.^2 - k3.k30)./(k.^2.(k1(i).^2 + k2.^2));
C2 = k2.*k0.^2./((k1(i).^2 + k2.^2).^(3/2)).*atan2((beta(i).*k1(i).*sqrt(k1(i).^2 + k2.^2)),(k0.^2 - k30.*k1(i).*beta(i)));
xhsi1 = C1 - k2./k1(i).*C2;
xhsi1_q = xhsi1.^2;
phi_11 = E_k0./(4.*pi.k0.^4).(k0.^2 - k1(i).^2 - 2.*k1(i).*k30.*xhsi1 + (k1(i).^2 + k2.^2).*xhsi1_q);
end
I recall this function within the main code as follows
for l = 1:numel(k1)
phi11 = #(k2,k3) phi_11(k1,k2,k3,l)
F11(l) = integral2(phi,-1000,1000,-1000,1000);
end
at it seems it works.