I want to translate my matlab code fortran?

조회 수: 3 (최근 30일)
Anu G
Anu G 2018년 12월 24일
댓글: Anu G 2018년 12월 26일
theta=0:10:60; % 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(mod(roftheta));
% ^----- here
grid on
plot(theta,r0)
  댓글 수: 2
Image Analyst
Image Analyst 2018년 12월 24일
What do you mean by "fortran" in your subject line and tag. Do you want to translate this code INTO the FORTRAN programming language? If so, why, and it looks simple enough so why can't you do it?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 12월 24일
편집: KSSV 2018년 12월 24일
Read the documentation of mod. It takes two inputs, you have to decide what should be the input. For demo, below I have taken mod(n,2).
theta=0:10:60; % 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(mod(roftheta,2));
% ^----- here
grid on
plot(theta,r0)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by