perl script to matlab code conversion
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Simon
el 19 de Nov. de 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
el 19 de Nov. de 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.)
Respuestas (0)
Ver también
Categorías
Más información sobre String Parsing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!