help-octave
[Top][All Lists]
Advanced

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

Re: [sligthly OT] phantom line error


From: roberto
Subject: Re: [sligthly OT] phantom line error
Date: Thu, 15 Sep 2005 18:35:06 +0200

On 9/15/05, Shai Ayal <address@hidden> wrote:
> In this script you have a function.
> All variables inside the function are local to that function.
> If you need a value from the function, you can either:
> 1) put it as a return value i.e.
> function[E_X,r] = E_X(R)
> 2) declare it as global both inside the function and at the command line
> 

thanks, i tried the first of the two options you gave me and i
modified the code accordingly, but the situation is the same. I have
no way to access the value of A, E or any other variable to be
returned; i attach the code here, any suggestion is welcome : )

function [E_X, A, r] = E_X(R)

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

r = linspace(R,1000,300);
nr = length(r);
A = zeros(1,R);
for j = 1:nr
        x = linspace(1,R,300);
        nx = length(x);
        delta = R/nx;
        for i = 1:nx
                if ((i)*delta) < 0
                        F_int(i) = 0;
                elseif ((i)*delta) > 110
                        F_int(i) = 1;
                else
                        F_int(i) = F_X((i)*delta,r(j),R);
                end
        A(j)   = sum(F_int)*delta;
        E_X(j) = R - A(j);
        end
A = [A A(j)];
E = [E_X E_X(j)];
end

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

-- 
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
-------------------------------------------------------------



reply via email to

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