help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: phantom line error


From: Hall, Benjamin
Subject: RE: phantom line error
Date: Mon, 12 Sep 2005 08:24:43 -0400

It looks like you are missing an "endif" (or "end") statement around line 21

-----Original Message-----
From: roberto [mailto:address@hidden
Sent: Monday, September 12, 2005 6:48 AM
To: address@hidden
Subject: Re: phantom line error


On 9/12/05, Bill Denney <address@hidden> wrote:
> We need to see the script to be able to help you with the problem.
> 
> On Mon, 12 Sep 2005, roberto wrote:
> 
> > i'm running an octave script and today i got the following strange
>>error:
> > ######
> > octave-2.1.69:52> E_X
> > parse error near line 58 of file
> >
>>/home/roberto/NETs/temix/routing-temix/giacomo/packetostatic/MATLAB/Octave
/E_X.m
> >
> > syntax error
> > #######

here is the script

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[E_X] = E_X(R)

% R = trasmission radius
% r = distance from destination
% uses 1000 points to integrate

r = linspace(R,10,10);
A = zeros(1,R);
for j = R:length(r)
        x = linspace(0,R,10);
        n = length(x);
        delta = R/n;
        for i = 1:n
                if ((i-1)*delta) < 0
                        F_int(i) = 0;
                elseif ((i-1)*delta) > R
                        F_int(i) = 1;
                else
                        F_int(i) = F_X((i-1)*delta,r(j),R);
        end
        A(j)   = sum(F_int)*delta;
        E_X(j) = R - A(j);
end

save E_X_ E_X
% for Octave-to-MATLAB compatibility
save -mat E_X_mat E_X

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [F_X] = F_X(x,r,R)
        l = (0.1*sqrt(pi))*exp(-r^2 / 100); 
        F_X = 1 - exp(-l*area_x(x,R));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [area_x] = area_x(x,R)
%in our case the following holds
d = R;

a1 = R^2*acos((R^2+d^2-x^2)/(2*d*R));
a2 = x^2*acos((x^2+d^2-R^2)/(2*x*d));

s = 0.5*(R+x+d);
a3 = 2*sqrt(s*(s-R)*(s-x)*(s-d));

if (x >= d-R)&(x <= R)
    area_x = a1+a2-a3;
elseif (x > R)
        disp('x>R, not positive approach to destination');
    return;
else 
        area_x = 0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

also "wc -l" command on linux tells me that lines are two less than
octave opinion




-- 
roberto
debian sarge, kernel 2.6.8



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]