Function in Fortran to Funciton in Matlab
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
James Tursa
on 8 Feb 2019
Edited: James Tursa
on 8 Feb 2019
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
More Answers (0)
See Also
Categories
Find more on Fortran with MATLAB 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!