Home > Enterprise >  how can i execute this function for range of values؟
how can i execute this function for range of values؟

Time:02-14

if I have this function enter image description here

where f has values (18 19 20 21 22), and I should had different values of the function for each value of f and plot each value. I try to make f as vector start from 18:22 but it gives result from 1 to 22. same result when I use for loop that's my code how can i modify it to take the values within the range only?

clc
fc=20;
theta=80;
N=16;
f=18:22;
g_m(f)=(sin((N*pi/2).*sin(theta).*(f/fc-1)))./sqrt(N).*(sin(pi/2).*(f/fc-1));
g_p(f)=exp(1j*0.5*(N-1).*pi*sin(theta).*(f/fc-1));
gain(f)=g_m(f).*g_p(f);
figure(1);
plot(f,g_m(f));

CodePudding user response:

I believe this should give you enough information:

f = 5:7;
g(f)= [2, 2, 5]
g =  
   0   0   0   0   2   2   5
  • Related