perl script to matlab code conversion
이전 댓글 표시
the following is the program that was converted from perl version to matlab. when executed in perl i got "pa" value around 9.81..but in matlab iam getting only 0.0763..can someone tel me y?..i need this answer badly pls
clc;
clear all;
j=1:6;
for i=0:length(j)
beta=2^i;
alow=0;
ahigh=10000;
pa=0;
r=3;
eps=0.1;
gminus=0;
gplus=0;
g=0;
fa=0;
while((ahigh-alow)>eps)
pa=(alow+ahigh)/2;
fa=1-(exp(-((((2^r)-1)/pa)^(beta/2))));
gminus=(((fa-1)/pa)*(pa-eps))+1;
glus=(((fa-1)/pa)*(pa+eps))+1;
fminus=1-(exp(-((((2^r)-1)/(pa-eps))^(beta/2))));
fplus=1-(exp(-((((2^r)-1)/(pa+eps))^(beta/2))));
if(((gminus<fminus)&&(gplus>fplus))==1)
alow=pa;
else
ahigh=pa;
end
disp(pa)
end
댓글 수: 4
Walter Roberson
2013년 11월 19일
That code would definitely bomb in perl, so you could not have gotten 9.81 when you executed it in perl.
shobi swaminathan
2013년 11월 19일
Simon
2013년 11월 19일
Hi!
It's not so easy to tell where the difference comes from if we only know the matlab code and not the perl code.
BTW, your code is missing an "end" at the end.
Walter Roberson
2013년 11월 19일
The poster has indicated that this code was executed in perl. Which is not plausible, as perl requires $ or @ before each variable name (except sometimes for file handles.)
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!