help-octave
[Top][All Lists]
Advanced

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

Re: lsode use


From: Juan Pablo Carbajal
Subject: Re: lsode use
Date: Wed, 26 Aug 2015 15:19:32 +0200

On Wed, Aug 26, 2015 at 2:07 PM, Céline <address@hidden> wrote:
> Juan Pablo Carbajal-2 wrote
>> Céline, it seems you do not abide to the mailing list rules. I wont
>> continue helping you.
>> Check the Octave manual
>> http://www.gnu.org/software/octave/doc/interpreter/
>
>
> Don't understand why you're so rude,
> When I reply via the forum it's not ok, when I do it by mail it is not ok
> neither even if I answer at the bottom. It's the first time I come on this
> kind of forum and it is not clear for me, so I try to do my best.
>
> Anyway, I know that there is a documentation but I've read what I thought
> that could be helping, otherwise I would not be asking on a forum.
>
> Thank you for your begin of help.
>
>
>
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/lsode-solver-problem-tp4672270p4672295.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave

Céline,

Ok, it seems now you can answer at the bottom. Thank you.

When asking users for input is good to separate function
implementation from the way you collect the data.
A common way of having a parametrized function is to pass all
arguments in a structure. Se the following example

function y = linear (x, p)
    y = p.A + p.B*x
endfunction

Then the user could do

x           = linspace (-1,1,10).';
params = struct ("A",0, "B",-1);
y           = linear (x, params);

plot (x,y)


Another way is to use inputParser, but since it uses classdef, and the
help for classdef is not working, you will have to read the help form
the source code or form the web.
Using inputParser would allow you to do things like

function y = linear (x, varargin)
  parser = inputParser ();
  parser.FunctionName = "linear";
  parser.addParamValue ("slope", 1);
  parser.addParamValue ("offset",0);
  parser.parse(varargin{:});

  A   = parser.Results.slope;
  B   = parser.Results.offset;

  y = A + B*x
endfunction

and the user can do things like

y = linear (x) # default line
y = linear (x, "slope",-2) # change slope, offset default
y = linear(x,"slope",2,"offset") # change both parameters


Hope this helps.



reply via email to

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