help-octave
[Top][All Lists]
Advanced

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

Re: variables `inheriting' values, rounding


From: Jordi Gutiérrez Hermoso
Subject: Re: variables `inheriting' values, rounding
Date: Tue, 26 Jan 2010 09:34:10 -0600

Mike, although there isn't an official policy on this mailing list,
I'd like to encourage you to not top-post and avoid HTML emails if
possible. It's an old email convention many of us still like.

2010/1/26 Mike B. <address@hidden>
> As an example. I have a structure A which is defined in the begining
> of the code but it should actually inherit values from another
> structure defined later, something like algorithm_parameters =
> settings; . . . settings = [ 0, 0.4 ];

My earlier suggestion to make settings a function that returns the
actual values you want might work here, assuming that the overhead of
a function call isn't a problem in your algorithm.

Barring that, Octave can do functional programming rather well, so I
would structure your code so that your algorithm is contained in a
function and settings is a parameter to that function.

> Also, is there a function to round real numbers to a certain
> accuracy

If you go to http://octave.sourceforge.net, click on function
reference at the top and then look at the alphabetical list, you will
find that round is a built-in function that rounds to the nearest
integer. You can easily use this to round to whatever decimal place
you want.

HTH,
- Jordi G. H.


reply via email to

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