perl script to matlab code conversion
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Simon
il 19 Nov 2013
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
il 19 Nov 2013
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.)
Risposte (0)
Vedere anche
Categorie
Scopri di più su String Parsing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!