Function in Fortran to Funciton in Matlab

조회 수: 1 (최근 30일)
Wazy sky
Wazy sky 2019년 2월 8일
댓글: Wazy sky 2019년 2월 9일
Hi,
Would be so much appreaciated if anyone can help with converiting the next code from fortran to Matlab. This code is part of larger one. this part is return the calculated F0 to the original code.
Thanks
FUNCTION F0(n,x)
INTEGER n
REAL F0,x
INTEGER j
REAL bk,bkm,bkp,tox,F00,F01
if (n.lt.2) pause 'bad argument n in F0'
tox=2.0/x
bkm=F00(x)
bk=F01(x)
do 11 j=1,n-1
bkp=bkm+j*tox*bk
bkm=bk
bk=bkp
11 continue
F0=bk
return
END

채택된 답변

James Tursa
James Tursa 2019년 2월 8일
편집: James Tursa 2019년 2월 8일
function result = F0(n,x)
if( n<2 )
error('bad argument n in F0')
end
tox=2.0/x;
bkm=F00(x);
bk=F01(x);
for j=1:n-1
bkp=bkm+j*tox*bk;
bkm=bk;
bk=bkp;
end
result=bk;
return
end

추가 답변 (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