[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Updating a variable
From: |
Juan Pablo Carbajal |
Subject: |
Re: Updating a variable |
Date: |
Wed, 18 Jan 2012 15:13:10 +0100 |
On Wed, Jan 18, 2012 at 6:47 AM, witham <address@hidden> wrote:
> I believe this will be very simple, but I don't see what to do. I couldn't
> find anything in Octave FAQs about this. Why isn't A being updated?
>
>>> d=1
> d = 1
>>> A=d*8
> A = 8
>>> d=2
> d = 2
>>> A
> A = 8
>
> A stays = to 8, why doesn't it change to 16? How can I get it to change to
> 16?
>
> Thanks.
>
> --
> View this message in context:
> http://octave.1599824.n4.nabble.com/Updating-a-variable-tp4305773p4305773.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
Hi,
When you do
A = d*8
The variable A stores the value of the result. It is not linked to d
in anyway. To produce such behavior you could define A as a function
of d, for example
> A =@(x)x*8
Then
> d = 1;
>A(d)
ans = 8
>A(3)
ans = 24
etc...
--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/