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 21:12:52 +0300 (IDT)

You should call the function from the octave command line like this:
[EX, A, r] = E_X(R);

now you should be able to see EX , A and R

note that the return value was changed to EX so that it won't clash with
the E_X functions name.

If this helped you than I really recommend you do some introductory
reading on the matlab language so that you understand basic concpts like
scripts, functions, local variables etc. I have no recommendation for such
material, but I'm sure googling will turn something up

Shai

On Thu, 15 Sep 2005, roberto wrote:

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

-- 
Shai Ayal, Ph.D.
Head of Research
BioControl Medical (B.C.M.) Ltd.
3 Geron St.
Yehud 56100
ISRAEL
E: address@hidden
T: +972 3 6322126 ext 223
F: +972 3 6322125



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