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: Shai Ayal
Subject: Re: [sligthly OT] phantom line error
Date: Thu, 15 Sep 2005 14:13:25 +0300
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

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


Shai

roberto wrote:
On 9/12/05, roberto <address@hidden> wrote:

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


i have also another question for you about this code:
if i run it and then i type at the octave prompt something like:
octave2.1:10>r
error: `r' undefined near line 10 column 1

also if i take a look at:
octave2.1:11>whos
*** currently compiled functions:

  Prot Name        Size                     Bytes  Class
  ==== ====        ====                     =====  =====
   rwd E_X        -1x-1                         0  user-defined function
   rwd F_X        -1x-1                         0  user-defined function
   rwd area_x     -1x-1                         0  user-defined function

Total is 3 elements using 0 bytes

*** local user variables:

  Prot Name            Size                     Bytes  Class
  ==== ====            ====                     =====  =====
   rw- __nargin__      1x1                          8  scalar

Total is 1 element using 8 bytes

then i cannot see anything regarding the variables i defined inside the script;
but i do not understand why; i can not even retrieve the values
interesting for my calculation...

thak you about any help

--
roberto
debian sarge



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