help-octave
[Top][All Lists]

## Re: error with "end"

 From: Daniel Heiserer Subject: Re: error with "end" Date: Wed, 15 Sep 1999 07:20:59 +0200

```Hi,

correction for "end":
========================================================================
< M A T L A B >
Version 5.3.0.10183 (R11)
Jan 21 1999

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, type tour or visit www.mathworks.com.

>> help end

END Terminate scope of FOR, WHILE, SWITCH, TRY, and IF statements.
Without END's, FOR, WHILE, SWITCH, TRY, and IF wait for further
input.
Each END is paired with the closest previous unpaired FOR, WHILE,
SWITCH, TRY or IF and serves to terminate its scope.

END can also serve as the last index in an indexing expression.  In
that context, END = SIZE(X,k) when used as part of the k-th index.
Examples of this use are, X(3:end) and X(1,1:2:end-1).  When using
END
to grow an array, as in X(end+1) = 5, make sure X exists first.

END(A,K,N) is called for indexing expressions involving the object A
when END is part of the K-th index out of N indices.  For example,
the expression A(end-1,:) calls A's END method with END(A,1,2).

>> a=1:10;
>> a(1:end)

ans =

1     2     3     4     5     6     7     8     9    10

>> end
Warning: Unmatched "end".
>> which end
end is a built-in function.
>>
========================================================================

For me it seems, that you either
o       have an old matlab version (4.0)
o       or something else

"end" is a valid 'function/value'.

Bye daniel

>
> >
> > why does octave continually give me an error with the code...
> >
> > "b = reshape(x,s(n+1:end));"
>
> try changing `end' with length(s). This question has already arised
> here, `end' being the length of a vector. At the time I remember that
> John Eaton asked if this was a valid Matlab construct, but nobody
> answered. So I opened my win95 under sco-unix ;-), run my matlab 4.0,
> and typed:
>
> » a=1:10;
> » a(1:end)
>
> ans =
>
>      []
>
> » help end
>
>  END    Terminates the scope of FOR, WHILE and IF statements.
>         Without END's, FOR, WHILE, and IF wait for further input.
>         Each END is paired with the closest previous unpaired
>         FOR, WHILE, or IF and serves to terminate its scope.
>
> » version
>
> ans =
>
> 4.0
>
> »
>
> so it seems that `end' is not valid here (neither with a strings)but I
> remember using it in matlab... when I use to use matlab.
>
> Also, under octave,
>
>  usage: reshape (a, m, n)
>
>  Form an m x n matrix from the elements of a (taken in Fortran's
>  column major ordering).
>
> >                        ^
> > specifically octave tells me that
> > "parse error near lin 16 of file..."
> >
> > its has to do with "n+1:end" anyone know why this doesnt work? im trying to
> > port all my matlab code to octave, and i need this function to be working by
> > tommrow morning. thanks.
> >
> > (the code comes from Matlabs "shiftdim.m"...
> >  if (n > 0)
> >     n = rem(n-1,ndims(x))+1;
> >     if (isequal(siz(1:n),ones(1,n)))
> >       s = [siz ones(1,n+2-length(siz))];
> >       b = reshape(x,s(n+1:end));
> >                                     ^
> >
> > thanks.
> >
> > ---------------------------------------------------------------------
> > Octave is freely available under the terms of the GNU GPL.  To ensure
> > that development continues, see www.che.wisc.edu/octave/giftform.html
> > Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
> > ---------------------------------------------------------------------
>
> --
> Joao Cardoso, INESC  |  e-mail:
> R. Jose Falcao 110   |  tel:    + 351 2 2094345
> 4050 Porto, Portugal |  fax:    + 351 2 2008487
>
> ---------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.  To ensure
> that development continues, see www.che.wisc.edu/octave/giftform.html
> Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
> ---------------------------------------------------------------------

--
Mit freundlichen Gruessen
Daniel Heiserer
-----
--------------------------------------------------------------
Dipl.-Phys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820

---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure