[Scilab-users] {EXT} ugly code improvement (with vectorization)

Dang Ngoc Chan, Christophe Christophe.Dang at sidel.com
Tue Jun 27 11:33:50 CEST 2017


Hello Paul,

> De : Carrico, Paul
> Envoyé : mardi 27 juin 2017 09:06
>
> -  to capture the non-null values of each line from the 5th column - each row can have different "length"
> - the 4th column indicates how many values there're i.e the length
> - Then to put this values in a vector previously initialized
>  [
> Elements = [...]
>    1.     1.    29.    8.    81.    82.     83.     124.    165.    164.    163.    122.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.    0.     0.    0.    0.    0.
[...]

I suggest:

1. Extract foo = Elements(:, 5:$)'

2. Use foo2 = foo(:) to have a vector.

3. Remove the zeros with something like index = (foo2 == 0) ; foo2(index) = []

Would this work?

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



More information about the users mailing list