Re: switchcase problem in R12 v6.1



Hi,
the error message tells you what's wrong: ode15s gives t, c, and flag
to your function trial. flag has the value 'init', which is not handled by
your function, so you should write something like

function varargout= trial (t, c, flag)

switch flag
case 'init'
varargout{1}=<your initial value comes here>;
....

Titus

"sarma" <sarma_418@xxxxxxxxxxx> schrieb im Newsbeitrag
news:ef17218.-1@xxxxxxxxxxxxxxxxxxx
> iam encountering a strange problem using switch case. i'am trying
> call a function named trial (trial.m) and calling it from command
> prompt using ode15s, but i get a error saying unknown flag 'init'.
> MATLAB6.1 R12
>
> details given below::::::PLZ help me out:::::::::
>
> M-file name trial
>
> function varargout= trial (t, c, flag)
>
> switch flag
> case ''
> varargout{1}=f(t,c);
>
> case 'jpattern'
>
> varargout{1} = jpattern(t,c);
>
> case 'mass'
>
> varargout{1} = mass(t,c);
> otherwise
>
> error(['Unknown flag ''' flag '''.']);
> end
> % ------------------------------------------------------------
>
> function S = jpattern(t,c)
> %code for jpattern
>
> %---------------------------------------------------------------
>
> function M = mass(t,c)
> %code for mass
> %---------------------------------------------------------------
>
> function Gi=jacobianri(t,cp)
> %code for jacobianri
> %---------------------------------------------------------------
>
> while running at command prompt!!
>
> options=odeset('OutputFcn','odeplot','OutputSel',[ind],'JPattern','on'
> ,'Mass','on');
>
> [t c Y]= ode15s('trial',[0 ta], cinit,options);
>
> ----------------------------------------------------------------
> ERRORS Encountered!!!!
>
> ??? Error using ==> trial
> Unknown flag 'init'..
>
> Error in ==>
> E:\MATLAB\toolbox\matlab\funfun\private\odearguments.m
> On line 53 ==> [def_tspan,def_y0,def_options] =
> feval(ode,[],[],'init',extras{:});
>
> Error in ==> E:\MATLAB\toolbox\matlab\funfun\ode15s.m
> On line 212 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0,
> f0, args, ...
>
> Error in ==> ..\test.m
> On line 61 ==> [t c Y]= ode15s('trial',[0 ta],
> cinit,options,flag);


.



Relevant Pages

  • Re: changevalue and newvalue
    ... I forgot to mention initializing it in Init. ... Note that the var declaration needs to be placed above the event ... flag logical ...
    (comp.databases.paradox)
  • Re: managing kallsyms_addresses
    ... we don't to remove the symbols from the init section ... One thing that did cross my mind though, is stuff like lockdep. ... freeing init sections" flag together with the function pointer, ... to keep the init symbols anyway) and the second solution could be simply ...
    (Linux-Kernel)
  • Re: managing kallsyms_addresses
    ... we don't to remove the symbols from the init section when the init section is freed. ... If we run a locking sequence that is called from init code, and later a different locking sequence is used when we already freed init data, how can the debug information show the names of the functions that generated the previous locking sequence? ... It seems that the only "correct" approach would be to store a "before freeing init sections" flag together with the function pointer, and then have a kallsyms interface that could receive this flag to know where to look. ... the first solution can not be used at all and the second solution could be simply implemented by having a default value for the flag that is the "current state" for that flag... ...
    (Linux-Kernel)
  • Re: Making a Part of code to be executed once
    ... making this will execute the code only once and i'm never going to ... change the flag to true ... i can't use the init() method... ... repercusion overall. ...
    (microsoft.public.dotnet.languages.csharp)