[Scilab-users] Converting string months to month numbers

Jens Simon Strom j.s.strom at hslmg.de
Thu Oct 20 14:36:49 CEST 2016


Hi Mike,
That is exactly what I needed.
Solved! Thanks!
Regards
Jens
-------------------------------------------------------------------------------------------------
Am 20.10.2016 13:31, schrieb Mike Page:
> Hi Jens,
>
> grep does something like what you want.
>
> -->[r,w]=grep(Ms,M);
> -->matrix(w,size(Ms))
>  ans  =
>
>     12.    4.
>     2.     12.
>     6.     7.
>
> Not sure why grep produces a vector when searching for a matrix, but 
> it seems that way.
>
> HTH,
> Mike.
>
>
> On 20 October 2016 at 10:32, Jens Simon Strom <j.s.strom at hslmg.de 
> <mailto:j.s.strom at hslmg.de>> wrote:
>
>     Hallo,
>     Given the string vector
>
>     M=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
>     which implicitly maps the string representation of the months to their number representataion I would like to map any string matrix containing elements of M into a numercal matrix showing the month numbers.
>     E. g.
>     Ms=['Dec','Apr';'Feb','Dec';'Jun','Jul']
>     should be converted to
>     Mn=[12,4;2,12;6,7].
>
>     Ho can that be done in a vectorial style?
>
>     Backward (given Mn) it is easier to me:
>     Ms=matrix(M(Mn),size(Mn))
>
>     Regards
>     Jens
>
>
>     _______________________________________________
>     users mailing list
>     users at lists.scilab.org <mailto:users at lists.scilab.org>
>     http://lists.scilab.org/mailman/listinfo/users
>     <http://lists.scilab.org/mailman/listinfo/users>
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161020/8e2be66a/attachment.htm>


More information about the users mailing list