[Scilab-users] how to faster EVSTR?

classic Classic list List threaded Threaded
7 messages Options
anna78 anna78
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] how to faster EVSTR?

Hi all,

I have a 1 Milion entries array of STRING type (test_str array), I should
convert to number (test_numer array).

I do as follow:
test_number=evstr(test_str)

It looks like working but it takes a not acceptable time...

Do you have a more clever idea?

---
Sub-question: I have such a long string array because I get it from an
uicontrol 'userdata' and it looks to me only string data can be set as
'userdata'.
Is that true or, in fact, I could simply set the user data as a number array
(without converting it in string witn the 'string' command)?
Now I do as follows:
"set(gcbo,"userdata",[spectrum_unit_x,
string(spectrum(:,1)'),string(spectrum(:,2)')])"

--
Many thanks
cheers
Anna



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété Denis Crété
Reply | Threaded
Open this post in threaded view
|

Re: how to faster EVSTR?

Hello,
For the first question: did you try
test_number= msscanf(-1,test_str,'%f');
or
test_number= strtod(test_str);
?
HTH
Denis
*********************************************
Hi all,

I have a 1 Milion entries array of STRING type (test_str array), I should
convert to number (test_numer array).

I do as follow:
test_number=evstr(test_str)

It looks like working but it takes a not acceptable time...

Do you have a more clever idea?

---
Sub-question: I have such a long string array because I get it from an
uicontrol 'userdata' and it looks to me only string data can be set as
'userdata'.
Is that true or, in fact, I could simply set the user data as a number array
(without converting it in string witn the 'string' command)?
Now I do as follows:
"set(gcbo,"userdata",[spectrum_unit_x,
string(spectrum(:,1)'),string(spectrum(:,2)')])"

--
Many thanks
cheers
Anna



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} how to faster EVSTR?

In reply to this post by anna78
Hello,

> De : anna78
> Envoyé : lundi 21 octobre 2019 16:02
>
> test_number=evstr(test_str)
>
> It looks like working but it takes a not acceptable time...
>
> Do you have a more clever idea?

You might try strtod()

Generally, the evaluation or execution of strings should be avoided
because one could put some malevolent code inside a string.

Hope this helps,

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

General
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.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Chin Luh Tan Chin Luh Tan
Reply | Threaded
Open this post in threaded view
|

Re: how to faster EVSTR?

In reply to this post by Denis Crété
For the sub-question, it is not true that userdata can only have string data. It could be any datatype of Scilab (at least the common one, :))

the reason you could not set the numeric data likely due to you're trying to mix string and number:
[spectrum_unit_x, string(spectrum(:,1)'),string(spectrum(:,2)')]
 
I believe your "spectrum_unit_x" is in string so you need to convert the second and 3rd to string to match the datatype.

1 option is that, you could save them in list:

set(gcbo,"userdata", list(spectrum_unit_x, spectrum(:,1)',spectrum(:,2)')

then you should be able to extract the data by using the index.

mydata = get(gcbo,'userdata')
mydata(2) and mydata(2) for the spectrum 1 and 2 respectively.

hope this helps.

CL


---- On Mon, 21 Oct 2019 22:37:17 +0800 CRETE Denis <[hidden email]> wrote ----

Hello,
For the first question: did you try
test_number= msscanf(-1,test_str,'%f');
or
test_number= strtod(test_str);
?
HTH
Denis
*********************************************
Hi all,

I have a 1 Milion entries array of STRING type (test_str array), I should
convert to number (test_numer array).

I do as follow:
test_number=evstr(test_str)

It looks like working but it takes a not acceptable time...

Do you have a more clever idea?

---
Sub-question: I have such a long string array because I get it from an
uicontrol 'userdata' and it looks to me only string data can be set as
'userdata'.
Is that true or, in fact, I could simply set the user data as a number array
(without converting it in string witn the 'string' command)?
Now I do as follows:
"set(gcbo,"userdata",[spectrum_unit_x,
string(spectrum(:,1)'),string(spectrum(:,2)')])"

--
Many thanks
cheers
Anna



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
anna78 anna78
Reply | Threaded
Open this post in threaded view
|

Re: how to faster EVSTR?

it works perfectly!
many thanks!
Anna



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Chin Luh Tan Chin Luh Tan
Reply | Threaded
Open this post in threaded view
|

Re: how to faster EVSTR?

welcome and great it works for you.

CL


---- On Tue, 22 Oct 2019 19:34:17 +0800 anna78 <[hidden email]> wrote ----

it works perfectly!
many thanks!
Anna



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} how to faster EVSTR?

In reply to this post by Christophe Dang Ngoc Chan
Le 21/10/2019 à 16:39, Dang Ngoc Chan, Christophe a écrit :
Hello,

De : anna78
Envoyé : lundi 21 octobre 2019 16:02

test_number=evstr(test_str)

It looks like working but it takes a not acceptable time...

Do you have a more clever idea?
You might try strtod()

Right.
evstr() is slower mainly because, historically, it includes some concatenation features that enables it not working in an element-wise way, like with

--> evstr(["1:3" "4" ; "5" "7:9"])
 ans  =
   1.   2.   3.   4.
   5.   7.   8.   9.


This was an unexpected (and undocumented) complication when debugging and upgrading
evstr() 2 years ago. We had to (temporarily) renounce to some element-wise processing.

However, in order to avoid breaking the back-compatibility, such a element-wise processing
could be implemented through a"by-element" optional flag. Then, the sizes of the input and
output would match, and some related bugs like the 10196 could be fixed, at last.

Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users