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!