Hi, I am trying to plot the following equation. Its showing error in mod function. Kindly clarify me how to use the mod function to get the proper output.

2 views (last 30 days)
theta=0:10:90;
rho=0.465;
%d=25; wrong
%k=0.99*(1+(1i*0.66)) ;
k=real(0.97+0.6402i);
poftheta=sqrt((k.^2)-(cos(theta).^2));
y=(rho*sin(theta))./(poftheta);
roftheta=((y-1)/(y+1));
r0=-20*log10(mod(roftheta));
hold on
grid on
plot(theta,r0)

Accepted Answer

madhan ravi
madhan ravi on 24 Dec 2018
Edited: madhan ravi on 24 Dec 2018
It should be abs instead of mod (assuming that you want to convert the negative sign to positive sign ? )
theta=0:10:90; % Note: if you reduce the step size you will get a smoother plot
rho=0.465;
%d=25; wrong
%k=0.99*(1+(1i*0.66));
k=real(0.97+0.6402i);
poftheta=sqrt((k.^2)-(cos(theta).^2));
y=(rho*sin(theta))./(poftheta);
roftheta=((y-1)./(y+1));
% ^---- missed dot
r0=-20*log10(abs(roftheta));
% ^----- here
grid on
plot(theta,r0)
  3 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!