From heinznabielek at me.com Thu Nov 1 09:27:11 2018 From: heinznabielek at me.com (Heinz Nabielek) Date: Thu, 01 Nov 2018 09:27:11 +0100 Subject: [Scilab-users] vector operation replacing for loop Message-ID: Sorry, Scilab friends, I am still not fluid with vector operations. Can someone rewrite the for loop for me into something much more efficient? n=1000; Z=grand(1,n,'nor',0,1); r=0.9; V=Z; for i=2:n; V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); end; The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values.... Heinz From guylaine.collewet at irstea.fr Thu Nov 1 13:06:07 2018 From: guylaine.collewet at irstea.fr (Collewet Guylaine) Date: Thu, 1 Nov 2018 13:06:07 +0100 (CET) Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: References: Message-ID: <002901d471db$451f6950$cf5e3bf0$@irstea.fr> Hello, Could you try this? I think this gives the same result as with the loop I think that the matrix mat could be probably built in a smarter way V=zeros(n,1); V(1)=Z(1); expo=1:n-1; vect=[zeros(1,n-1) r.^(expo-1)]; A=makematrix_toeplitz(vect); mat=A(n:$,1:n-1); V(2:$)=(Z(1)*r.^expo)'+sqrt(1-r^2)*mat*Z(2:$)'; Guylaine -----Message d'origine----- De?: users [mailto:users-bounces at lists.scilab.org] De la part de Heinz Nabielek Envoy??: jeudi 1 novembre 2018 09:27 ??: Users mailing list for Scilab Objet?: [Scilab-users] vector operation replacing for loop Sorry, Scilab friends, I am still not fluid with vector operations. Can someone rewrite the for loop for me into something much more efficient? n=1000; Z=grand(1,n,'nor',0,1); r=0.9; V=Z; for i=2:n; V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); end; The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values.... Heinz _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users From sgougeon at free.fr Thu Nov 1 13:40:55 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Thu, 1 Nov 2018 13:40:55 +0100 Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: References: Message-ID: <80d2cb85-40b9-2304-84c3-7b686139dc9e@free.fr> Hello, Le 01/11/2018 ? 09:27, Heinz Nabielek a ?crit : > Sorry, Scilab friends, I am still not fluid with vector operations. > Can someone rewrite the for loop for me into something much more efficient? > > n=1000; > Z=grand(1,n,'nor',0,1); > r=0.9; > V=Z; > for i=2:n; > V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); > end; > > The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values.... You may use filter(), with a feedback component (since V(i) depends on the previous state V(i-1) computed at the previous step). However, as shown below, a quick trial shows an initial discrepancy between filter() result and yours with the explicit loop. I don't know why. May be the setting for the initial condition should be carefully considered/tuned... n=1000; Z=grand(1,n,'nor',0,1); r=0.9; V=Z; for i=2:n; V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); end; y = filter(sqrt(1-r^2),[1 -r], Z); clf subplot(3,1,1), plot(Z), ylabel('input Z') subplot(3,1,2), plot(V), ylabel('V') d = abs(y-V); d(d==0) = %nan; subplot(3,1,3), plot2d("nl",d), title('filter() - V') -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: dhmcbnifdbmlkjck.png Type: image/png Size: 16996 bytes Desc: not available URL: From sgougeon at free.fr Thu Nov 1 15:16:03 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Thu, 1 Nov 2018 15:16:03 +0100 Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: <80d2cb85-40b9-2304-84c3-7b686139dc9e@free.fr> References: <80d2cb85-40b9-2304-84c3-7b686139dc9e@free.fr> Message-ID: Le 01/11/2018 ? 13:40, Samuel Gougeon a ?crit : > Hello, > > Le 01/11/2018 ? 09:27, Heinz Nabielek a ?crit : >> Sorry, Scilab friends, I am still not fluid with vector operations. >> Can someone rewrite the for loop for me into something much more efficient? >> >> n=1000; >> Z=grand(1,n,'nor',0,1); >> r=0.9; >> V=Z; >> for i=2:n; >> V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); >> end; >> >> The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values.... > > You may use filter(), with a feedback component (since V(i) depends on > the previous state V(i-1) computed at the previous step). > However, as shown below, a quick trial shows an initial discrepancy > between filter() result and yours with the explicit loop. > I don't know why. May be the setting for the initial condition should > be carefully considered/tuned... This is certainly the reason. For i=1, V(i-1) is unknown and must be somewhat provided. The last filter() option zi is not really documented (i have no time to go to the reference to get clear about how "the initial condition relative to a "direct form II transposed" state space representation." works. Trying to provide a value V(0) such that V(1)==Z(1) decreases the initial discrepancy by a factor 10. But it is still non zero. y = filter(sqrt(1-r^2), [1 -r], Z, Z(1)*(1-sqrt(1-r^2))/r); -------------- next part -------------- An HTML attachment was scrubbed... URL: From amonmayr at laas.fr Sat Nov 3 10:04:29 2018 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Sat, 03 Nov 2018 10:04:29 +0100 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ICBzY2lsYWIgbWtkaXIgYW5k?= =?utf-8?q?_UNC_path_support?= In-Reply-To: <35a81a6e-56e2-f288-45da-04aeea807bb4@free.fr> Message-ID: <6bc0-5bdd6480-13-46ed5a80@155733569> Hello all, In the end, I was not able to properly add unc support, as it implied some changes in a hard coded function (createdir). But I managed to roll out a dirty hack that works for our lab. For all of our machines, the user home directory comes from a remote server ( \\servernane\username\ ) and is usually also mounted as a letter drive ( let's say Z: ). What I have done is the following: 1) I wrote a path conversion function that takes a path, and if we are on Windows, retrieves the username ( echo %username% ) and checks whether the path starts with \\someServerName\username. It it's the case, it searches the mount table (don't know the proper name in Windows parlance: wmic LOGICALDISK LIST BRIEF ) to see whether a letter drive is associated to that unc path. If it's the case the path "\\someServerName\username\RestOfPath\" is changed into "Z:\RestOfPath\" ( assuming Z: was the letter drive associated to the unc server address). 2) I patched mkdir() to wrap the input path with my path conversion function. 3) I added a scilab.ini file that loads my path conversion function together with my patched mkdir function. So far, it has worked as expected, that is I was able to use atomsInstall without any issue. I think that more functions than just mkdir() should be patched for a proper unc path support (well "proper" as in it works in my really specific case). If you think that what I've done might be interesting for any of you, just get in touch and I'll get into more details. Cheers, Antoine Le Lundi, Octobre 29, 2018 19:40 CET, Samuel Gougeon a ?crit: > Le 29/10/2018 ? 16:17, Antoine Monmayrant a ?crit : > > Hi all, > > > > The lack of support for UNC path in scilab is a real issue in our lab (UNC path are Windows paths that looks like \\server\dir1\subdir1\). > > In particular it breaks atomsInstall for all the Windows users here as our home dir is mounted as a UNC path: \\servername\username. > > I found the main issue (I think) in mkdir() at line 88: > > subdirs = strsplit(NewDirectory, ["/" "\"]); > > obviously, splitting the path to the new directory is not going to give you something nice with a UNC path that starts with "\\". > > I have an idea to workaround this limitation, but there is still something I don't get in the logic of mkdir(): this splitting is associated with "bAddFirstDirSep", a variable that tries to detect something wrong with the first directory separator. > > Could anyone more knowledgeable than me explain why it is there and what is is doing? > > I would not want to reintroduce some bug with my modified version... > > On windows, we have > --> pathconvert("c:\",%f,%t,"u") > ans = > /cygdrive/c > > I don't know what we might do with this. There is no cygdrive on my > computer (AFAIK :/) > > Conversely, could you try something like > --> pathconvert(your_slashslash_path, %f, %t, "w") > > Samuel > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From sgougeon at free.fr Tue Nov 6 10:52:16 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Tue, 6 Nov 2018 10:52:16 +0100 Subject: [Scilab-users] =?utf-8?q?Re=C2=A0=3A_fftshift_and_ifftshift_are_w?= =?utf-8?q?ay_too_different?= In-Reply-To: <98348825-4536-9821-b612-010ae7a0495f@laas.fr> References: <248496656.993127881.1539093931290.JavaMail.root@zimbra75-e12.priv.proxad.net> <4f167b65-4986-7bd5-ccc7-68a4e99eed5b@free.fr> <98348825-4536-9821-b612-010ae7a0495f@laas.fr> Message-ID: <0fa4b4f7-4e46-6b00-300c-ed108dc0780e@free.fr> Le 10/10/2018 ? 12:39, amonmayr at laas.fr a ?crit : > Le 10/10/2018 ? 08:47, Samuel Gougeon a ?crit : >> Le 09/10/2018 ? 21:52, antoine monmayrant a ?crit : >>> Hello Samuel, >>> >>> Sorry I might not have made myself clear: fft and fftshift provide >>> the ability to perform transform along only one of the dimensions of >>> a multidimensional array. >>> Something like S(x,y,z) --[FFT along 3rd dim]--> >>> ffthift(ffft(S(x,y,z), -1,3),3)=?(x,y,kz). >>> In that case, you need to perform fft and eventually fftshift along >>> only the dimension of the transform. >>> ifftshift should also provide the same possibility to perform the >>> inverse transform: ?(x,y,kz) --[IFFT along 3rd dim]--> >>> iffthift(ffft(?(x,y,kz), +1,3),3)=S(x,y,z). >>> >>> This is a basic signal processing requirement in my field. >> >> Hello Antoine, >> >> Yes, you are right: in case of directional FFT and odd number of >> elements along the chosen direction, ifftshift can't presently be used. >> Could you please post the same remark on bugzilla? This bug/wish is >> not yet reported. > Done: http://bugzilla.scilab.org/show_bug.cgi?id=15799 This complementary feature is now implemented and proposed for Scilab 6.0.2 there . BR Samuel -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.carrico at esterline.com Tue Nov 6 12:28:47 2018 From: paul.carrico at esterline.com (Carrico, Paul) Date: Tue, 6 Nov 2018 11:28:47 +0000 Subject: [Scilab-users] plot3d and param3d Message-ID: <3A6B7233274DB449A2A0053A47684F953FF00FFA@BGS-EX01.auxitrol.ad> Dear All I'm trying to superimpose a basic line onto a 3D surface, but none of the parameters (color, thickness and so on) I'm trying to implement works: what I'm doing wrong? Thanks for your support Paul mode(0); clear function [z]=saddle(x, y) z = x^2 - y^2 endfunction n = 100; x = linspace(-2,2,n)'; // (n,1) matrix y = linspace(-1,3,n)'; // (n,1) matrix z = feval(x, y, saddle); // (n,n) matrix Line = [1 -2 -3 ; -2 -2 -3]; // plot scf(0); drawlater(); f = gcf(); f.figure_size = [1000, 1000]; f.background = color(255,255,255); a = gca(); a.font_size = 2; a.x_label.text = '$X$'; a.x_label.font_size = 4; a.y_label.text = '$Y$'; a.Y_label.font_size = 4; a.z_label.text = "$\sigma$"; a.z_label.font_size = 4; plot3d(x, y, feval(x, y, saddle)); surf = gce(); curve=gce(); param3d(Line(:,1),Line(:,2),Line(:,3)); e2 = gce(); p2 = e2.children; p2.thickness = 2 ; p2.foreground = color(255,0,0); p2.line_Style = 1; p2.mark_mode="on"; p2.mark_style = 0; p2.mark_size_unit="tabulated"; p2.mark_size = 1; p2.mark_foreground = color(255,0,0); p2.mark_background = color(255,0,0); drawnow(); EXPORT CONTROL : Cet email ne contient pas de donn?es techniques This email does not contain technical data -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Tue Nov 6 12:31:47 2018 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Tue, 6 Nov 2018 12:31:47 +0100 Subject: [Scilab-users] plot3d and param3d In-Reply-To: <3A6B7233274DB449A2A0053A47684F953FF00FFA@BGS-EX01.auxitrol.ad> References: <3A6B7233274DB449A2A0053A47684F953FF00FFA@BGS-EX01.auxitrol.ad> Message-ID: Hello, have you checked that the line is not *behind* the surface ? S. Le 06/11/2018 ? 12:28, Carrico, Paul a ?crit?: > > Dear All > > I?m trying to superimpose a basic line onto a 3D surface, but none of > the parameters (color, thickness and so on) ?I?m trying to implement > works: what I?m doing wrong? > > Thanks for your support > > Paul > > mode(0); > > clear > > function[*z*]=_saddle_(*x*, *y*) > > *z* = *x*^2 - *y*^2 > > endfunction > > n= 100; > > x= _linspace_(-2,2,n)'; /// (n,1) matrix/ > > y= _linspace_(-1,3,n)'; /// (n,1) matrix/ > > z= feval(x, y, _saddle_); /// (n,n) matrix/ > > Line= [1 -2 -3 ; -2 -2 -3]; > > /// plot/ > > _scf_(0); > > drawlater(); > > f= _gcf_(); > > f.figure_size= [1000, 1000]; > > f.background= color(255,255,255); > > a= _gca_(); > > a.font_size= 2; > > a.x_label.text= '$X$'; > > a.x_label.font_size= 4; > > a.y_label.text= '$Y$'; > > a.Y_label.font_size= 4; > > a.z_label.text= "$\sigma$"; > > a.z_label.font_size= 4; > > plot3d(x,y, feval(x, y, _saddle_)); > > _surf_= gce(); > > curve=_gce_(); > > param3d(Line(:,1),Line(:,2),Line(:,3)); > > e2= _gce_(); > > p2= e2.children; > > p2.thickness= 2 ; > > p2.foreground= color(255,0,0); > > p2.line_Style= 1; > > p2.mark_mode="on"; > > p2.mark_style= 0; > > p2.mark_size_unit="tabulated"; > > p2.mark_size= 1; > > p2.mark_foreground= color(255,0,0); > > p2.mark_background= color(255,0,0); > > drawnow(); > > */EXPORT CONTROL : > /**Cet email ne contient pas de donn?es techniques > This email does not contain technical data* > > > > _______________________________________________ > users mailing list > users at lists.scilab.org > https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.monmayrant at laas.fr Tue Nov 6 12:49:44 2018 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Tue, 6 Nov 2018 12:49:44 +0100 Subject: [Scilab-users] =?utf-8?q?Re=C2=A0=3A_fftshift_and_ifftshift_are_w?= =?utf-8?q?ay_too_different?= In-Reply-To: <0fa4b4f7-4e46-6b00-300c-ed108dc0780e@free.fr> References: <248496656.993127881.1539093931290.JavaMail.root@zimbra75-e12.priv.proxad.net> <4f167b65-4986-7bd5-ccc7-68a4e99eed5b@free.fr> <98348825-4536-9821-b612-010ae7a0495f@laas.fr> <0fa4b4f7-4e46-6b00-300c-ed108dc0780e@free.fr> Message-ID: Le 06/11/2018 ? 10:52, Samuel Gougeon a ?crit?: > Le 10/10/2018 ? 12:39, amonmayr at laas.fr a ?crit?: >> Le 10/10/2018 ? 08:47, Samuel Gougeon a ?crit?: >>> Le 09/10/2018 ? 21:52, antoine monmayrant a ?crit : >>>> Hello Samuel, >>>> >>>> Sorry I might not have made myself clear: fft and fftshift provide >>>> the ability to perform transform along only one of the dimensions >>>> of a multidimensional array. >>>> Something like S(x,y,z) --[FFT along 3rd dim]--> >>>> ffthift(ffft(S(x,y,z), -1,3),3)=?(x,y,kz). >>>> In that case, you need to perform fft and eventually fftshift along >>>> only the dimension of the transform. >>>> ifftshift should also provide the same possibility to perform the >>>> inverse transform: ?(x,y,kz) --[IFFT along 3rd dim]--> >>>> iffthift(ffft(?(x,y,kz), +1,3),3)=S(x,y,z). >>>> >>>> This is a basic signal processing requirement in my field. >>> >>> Hello Antoine, >>> >>> Yes, you are right: in case of directional FFT and odd number of >>> elements along the chosen direction, ifftshift can't presently be used. >>> Could you please post the same remark on bugzilla? This bug/wish is >>> not yet reported. >> Done: http://bugzilla.scilab.org/show_bug.cgi?id=15799 > > This complementary feature is now implemented and proposed for Scilab > 6.0.2 there . Nice! > > BR > Samuel > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Antoine Monmayrant LAAS - CNRS 7 avenue du Colonel Roche BP 54200 31031 TOULOUSE Cedex 4 FRANCE Tel:+33 5 61 33 64 59 email : antoine.monmayrant at laas.fr permanent email : antoine.monmayrant at polytechnique.org +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -------------- next part -------------- An HTML attachment was scrubbed... URL: From sgougeon at free.fr Tue Nov 6 12:55:56 2018 From: sgougeon at free.fr (sgougeon at free.fr) Date: Tue, 6 Nov 2018 12:55:56 +0100 (CET) Subject: [Scilab-users] =?utf-8?q?Re=C2=A0=3A__plot3d_and_param3d?= In-Reply-To: <3A6B7233274DB449A2A0053A47684F953FF00FFA@BGS-EX01.auxitrol.ad> Message-ID: <873364098.1347569284.1541505356735.JavaMail.root@zimbra75-e12.priv.proxad.net> Hello Paul, Your polyline is directly e2, not any child p2. Samuel From paul.carrico at esterline.com Tue Nov 6 13:53:58 2018 From: paul.carrico at esterline.com (Carrico, Paul) Date: Tue, 6 Nov 2018 12:53:58 +0000 Subject: [Scilab-users] =?iso-8859-1?q?=5BEXTERNAL=5D___Re=A0=3A__plot3d_a?= =?iso-8859-1?q?nd_param3d?= In-Reply-To: <873364098.1347569284.1541505356735.JavaMail.root@zimbra75-e12.priv.proxad.net> References: <3A6B7233274DB449A2A0053A47684F953FF00FFA@BGS-EX01.auxitrol.ad> <873364098.1347569284.1541505356735.JavaMail.root@zimbra75-e12.priv.proxad.net> Message-ID: <3A6B7233274DB449A2A0053A47684F953FF01035@BGS-EX01.auxitrol.ad> Indeed, thanks to all Still there're some aspects I'veto go deeper in under to master it Paul -----Message d'origine----- De?: users [mailto:users-bounces at lists.scilab.org] De la part de sgougeon at free.fr Envoy??: mardi 6 novembre 2018 12:56 ??: Users mailing list for Scilab Objet?: [EXTERNAL] [Scilab-users] Re?: plot3d and param3d Hello Paul, Your polyline is directly e2, not any child p2. Samuel _______________________________________________ users mailing list users at lists.scilab.org https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.scilab.org_mailman_listinfo_users&d=DwICAg&c=0hKVUfnuoBozYN8UvxPA-w&r=4TCz--8bXfJhZZvIxJAemAJyz7Vfx78XvgYu3LN7eLo&m=06xjdU3im4DE2mvBZxSuYXRyj8lt8TS2dyTCsEsq1z4&s=ViFKyLfML08_3_lTNfsFMm6wOq8_vdGAM4Qg8IBGLd8&e= EXPORT CONTROL : Cet email ne contient pas de donn?es techniques This email does not contain technical data From paul.carrico at esterline.com Wed Nov 7 12:35:34 2018 From: paul.carrico at esterline.com (Carrico, Paul) Date: Wed, 7 Nov 2018 11:35:34 +0000 Subject: [Scilab-users] function and vectorization Message-ID: <3A6B7233274DB449A2A0053A47684F953FF021B7@BGS-EX01.auxitrol.ad> Dear All Most of the time I've no issue in mixing functions and vectorization, but here I don't know why it does not work - one can see that using a vector I, the loop is called only ounce and I do not understand why? I've spent hours in such case showing I'm not fully at ease with it :-) :-) Any explanation? Thanks for your support Paul ##################################################################### mode(0) clear function [Scar_P]=Scalar_product(C, N, M) // Scalar product Scar_P = (M(1) - C(1))*(N(1) - C(1)) + (M(2) - C(2))*(N(2) - C(2)); printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); printf("M = (%g,%g)\n",M(1),M(2)); endfunction n = 10; C = rand(n,2); M = rand(n,2); N = rand(n,5); Scal = zeros(n); Scal2 = Scal printf(" ****************\n"); i = 1 : n; Scal(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:)) printf("\n ****************\n"); for i = 1 : n Scal2(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:)); end EXPORT CONTROL : Cet email ne contient pas de donn?es techniques This email does not contain technical data -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Wed Nov 7 13:39:43 2018 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 7 Nov 2018 13:39:43 +0100 Subject: [Scilab-users] function and vectorization In-Reply-To: <3A6B7233274DB449A2A0053A47684F953FF021B7@BGS-EX01.auxitrol.ad> References: <3A6B7233274DB449A2A0053A47684F953FF021B7@BGS-EX01.auxitrol.ad> Message-ID: <57e9ae30-5262-58d1-dbff-0948a9e28bf1@utc.fr> Hello, Try: function [Scar_P]=Scalar_product(C, N, M) // Scalar product Scar_P = (M(:,1) - C(:,1)).*(N(:,1) - C(:,1)) + (M(:,2) - C(:,2)).*(N(:,2) - C(:,2)); //printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); printf("M = (%g,%g)\n",M(1),M(2)); endfunction with (do not transpose N(i,1:2)) i= 1 : n; Scal(i)= _Scalar_product_(C(i,:),N(i,1:2),M(i,:)) S. Le 07/11/2018 ? 12:35, Carrico, Paul a ?crit?: > > ##################################################################### > > mode(0) > > clear > > function[*Scar_P*]=_Scalar_product_(*C*, *N*, *M*) /// Scalar product/ > > *Scar_P* = (*M*(1) - *C*(1))*(*N*(1) - *C*(1)) + (*M*(2) - > *C*(2))*(*N*(2) - *C*(2)); > > printf("C = (%g,%g)\n",*C*(1),*C*(2)); printf("N = > (%g,%g)\n",*N*(1),*N*(2)); printf("M = (%g,%g)\n",*M*(1),*M*(2)); > > endfunction > > n= 10; > > C= rand(n,2); > > M= rand(n,2); > > N= rand(n,5); > > Scal= zeros(n); Scal2 = Scal > > printf(" ****************\n"); > > i= 1 : n; > > Scal(i)= _Scalar_product_(C(i,:),N(i,1:2)',M(i,:)) > > printf("\n ****************\n"); > > fori = 1 : n > > Scal2(i) = _Scalar_product_(C(i,:),N(i,1:2)',M(i,:)); > > end > -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.crete at thalesgroup.com Wed Nov 7 13:54:00 2018 From: denis.crete at thalesgroup.com (CRETE Denis) Date: Wed, 7 Nov 2018 12:54:00 +0000 Subject: [Scilab-users] function and vectorization In-Reply-To: <57e9ae30-5262-58d1-dbff-0948a9e28bf1@utc.fr> References: <3A6B7233274DB449A2A0053A47684F953FF021B7@BGS-EX01.auxitrol.ad> <57e9ae30-5262-58d1-dbff-0948a9e28bf1@utc.fr> Message-ID: <1263eaac34e642a8afff6739613cc262@thalesgroup.com> Hello, If your matrices are not too big, diag((M-C)*(N(:,1:2)-C)') may do the job: it gives the same result as St?phane's solution HTH Denis [@@ THALES GROUP INTERNAL @@] Unit? Mixte de Physique CNRS / THALES 1 Avenue Augustin Fresnel 91767 Palaiseau CEDEx - France Tel : +33 (0)1 69 41 58 52 Fax : +33 (0)1 69 41 58 78 e-mail : denis.crete at thalesgroup.com http://www.trt.thalesgroup.com/ump-cnrs-thales http://www.research.thalesgroup.com De : users [mailto:users-bounces at lists.scilab.org] De la part de St?phane Mottelet Envoy? : mercredi 7 novembre 2018 13:40 ? : users at lists.scilab.org Objet : Re: [Scilab-users] function and vectorization Hello, Try: function [Scar_P]=Scalar_product(C, N, M) // Scalar product Scar_P = (M(:,1) - C(:,1)).*(N(:,1) - C(:,1)) + (M(:,2) - C(:,2)).*(N(:,2) - C(:,2)); //printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); printf("M = (%g,%g)\n",M(1),M(2)); endfunction with (do not transpose N(i,1:2)) i = 1 : n; Scal(i) = Scalar_product(C(i,:),N(i,1:2),M(i,:)) S. Le 07/11/2018 ? 12:35, Carrico, Paul a ?crit : ##################################################################### mode(0) clear function [Scar_P]=Scalar_product(C, N, M) // Scalar product Scar_P = (M(1) - C(1))*(N(1) - C(1)) + (M(2) - C(2))*(N(2) - C(2)); printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); printf("M = (%g,%g)\n",M(1),M(2)); endfunction n = 10; C = rand(n,2); M = rand(n,2); N = rand(n,5); Scal = zeros(n); Scal2 = Scal printf(" ****************\n"); i = 1 : n; Scal(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:)) printf("\n ****************\n"); for i = 1 : n Scal2(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:)); end -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.carrico at esterline.com Wed Nov 7 14:28:37 2018 From: paul.carrico at esterline.com (Carrico, Paul) Date: Wed, 7 Nov 2018 13:28:37 +0000 Subject: [Scilab-users] [EXTERNAL] Re: function and vectorization In-Reply-To: <57e9ae30-5262-58d1-dbff-0948a9e28bf1@utc.fr> References: <3A6B7233274DB449A2A0053A47684F953FF021B7@BGS-EX01.auxitrol.ad> <57e9ae30-5262-58d1-dbff-0948a9e28bf1@utc.fr> Message-ID: <3A6B7233274DB449A2A0053A47684F953FF021DB@BGS-EX01.auxitrol.ad> Thanks St?phane Works fine and fast (I'm speaking about my application :-) ) Paul EXPORT CONTROL : Cet email ne contient pas de donn?es techniques This email does not contain technical data De : users [mailto:users-bounces at lists.scilab.org] De la part de St?phane Mottelet Envoy? : mercredi 7 novembre 2018 13:40 ? : users at lists.scilab.org Objet : [EXTERNAL] Re: [Scilab-users] function and vectorization Hello, Try: function [Scar_P]=Scalar_product(C, N, M) // Scalar product Scar_P = (M(:,1) - C(:,1)).*(N(:,1) - C(:,1)) + (M(:,2) - C(:,2)).*(N(:,2) - C(:,2)); //printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); printf("M = (%g,%g)\n",M(1),M(2)); endfunction with (do not transpose N(i,1:2)) i = 1 : n; Scal(i) = Scalar_product(C(i,:),N(i,1:2),M(i,:)) S. Le 07/11/2018 ? 12:35, Carrico, Paul a ?crit : ##################################################################### mode(0) clear function [Scar_P]=Scalar_product(C, N, M) // Scalar product Scar_P = (M(1) - C(1))*(N(1) - C(1)) + (M(2) - C(2))*(N(2) - C(2)); printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); printf("M = (%g,%g)\n",M(1),M(2)); endfunction n = 10; C = rand(n,2); M = rand(n,2); N = rand(n,5); Scal = zeros(n); Scal2 = Scal printf(" ****************\n"); i = 1 : n; Scal(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:)) printf("\n ****************\n"); for i = 1 : n Scal2(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:)); end -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From sgougeon at free.fr Wed Nov 7 20:57:58 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Wed, 7 Nov 2018 20:57:58 +0100 Subject: [Scilab-users] filter(): How to use the last zi argument <= Re: vector operation replacing for loop In-Reply-To: References: <80d2cb85-40b9-2304-84c3-7b686139dc9e@free.fr> Message-ID: <035faa35-62d4-d43c-eec0-4eb0aef2e8be@free.fr> Hello, Is there anyone here that uses to use the last filter() optional argument? In the example of the thread reminded below: V = Z; for i=2:n V(i) = a*V(i-1) + b*Z(i); end the input is Z, the output is V, a and b are fixed parameters. The filter() description tells: > Syntax > ------ > [y,zf] = filter(B, A, x [,zi]) > > Parameters > ---------- > B : real vector : the coefficients of the filter numerator in > decreasing power order, or > a polynomial. > A : real vector : the coefficients of the filter denominator in > decreasing power order, > or a polynomial. > x : real row vector : the input signal > zi : real row vector of length max(length(a),length(b))-1: the > initial condition > relative to a "direct form II transposed" state space > representation. The default > value is a vector filled with zeros. So here i assume that zi is V(0) (so actually Z(1)). Then, how to get [Z(1) V(2:n)] as from the above loop? I have tried the following, without success: y = filter(b, [1 -a], Z); or y = [Z(1) filter(b, [1 -a], Z(2:$), Z(1))]; or y = filter(b, [1 -a], Z, Z(1)*(1-b)/a); The zi option has no example, and unless filter() is bugged, the way zi works/is taken into account is unclear. Any hint (before analyzing its hard code..)? Regards Samuel Le 01/11/2018 ? 15:16, Samuel Gougeon a ?crit : > Le 01/11/2018 ? 13:40, Samuel Gougeon a ?crit : >> Hello, >> >> Le 01/11/2018 ? 09:27, Heinz Nabielek a ?crit : >>> Sorry, Scilab friends, I am still not fluid with vector operations. >>> Can someone rewrite the for loop for me into something much more efficient? >>> >>> n=1000; >>> Z=grand(1,n,'nor',0,1); >>> r=0.9; >>> V=Z; >>> for i=2:n; >>> V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); >>> end; >>> >>> The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values.... >> >> You may use filter(), with a feedback component (since V(i) depends >> on the previous state V(i-1) computed at the previous step). >> However, as shown below, a quick trial shows an initial discrepancy >> between filter() result and yours with the explicit loop. >> I don't know why. May be the setting for the initial condition should >> be carefully considered/tuned... > > This is certainly the reason. For i=1, V(i-1) is unknown and must be > somewhat provided. The last filter() option zi is not really > documented (i have no time to go to the reference to get clear about > how "the initial condition relative to a "direct form II transposed" > state space representation." works. Trying to provide a value V(0) > such that V(1)==Z(1) decreases the initial discrepancy by a factor 10. > But it is still non zero. > y = filter(sqrt(1-r^2), [1 -r], Z, Z(1)*(1-sqrt(1-r^2))/r); > > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From kopac.jakub at gmail.com Wed Nov 7 21:06:27 2018 From: kopac.jakub at gmail.com (kjubo) Date: Wed, 7 Nov 2018 13:06:27 -0700 (MST) Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: References: Message-ID: <1541621187978-0.post@n3.nabble.com> Hello, precalculate the know values, I gain 40% faster execution time. Hope helps a bit... BR clc, clear, mode(0) n=1e6 Z=grand(1,n,'nor',0,1); Z=Z(:); r=0.9; tic() V1=Z; for ii=2:n; V1(ii)=r*V1(ii-1)+sqrt(1-r^2)*Z(ii); end; toc() tic() V2 = Z; k1 = sqrt(1-r^2).*Z; for ii=2:n; V2(ii) = r*V2(ii-1) + k1(ii); end; toc() isequal(V1,V2) -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From paul.carrico at esterline.com Thu Nov 8 15:54:22 2018 From: paul.carrico at esterline.com (Carrico, Paul) Date: Thu, 8 Nov 2018 14:54:22 +0000 Subject: [Scilab-users] How to remove 'Nan' in a matrix Message-ID: <3A6B7233274DB449A2A0053A47684F953FF0234C@BGS-EX01.auxitrol.ad> Dear All I'm wondering how I can, remove the 'Nan' that appears in a matrix ( with "find" I guess)? I'm nearly sure it comes from a div with 0. and I think I know why, but I've 2 options: - I can easily remove it and it's not an issue and not relevant for the final result (out of scope), - Or I can add conditions to avoid this, but it'll drastically speed down the CPU time (I'm using vectorization) Thanks for your support Paul EXPORT CONTROL : Cet email ne contient pas de donn?es techniques This email does not contain technical data -------------- next part -------------- An HTML attachment was scrubbed... URL: From Christophe.Dang at sidel.com Thu Nov 8 16:03:38 2018 From: Christophe.Dang at sidel.com (Dang Ngoc Chan, Christophe) Date: Thu, 8 Nov 2018 15:03:38 +0000 Subject: [Scilab-users] How to remove 'Nan' in a matrix Message-ID: Hello Paul, > De : users [mailto:users-bounces at lists.scilab.org] De la part de > Carrico, Paul Envoy? : jeudi 8 novembre 2018 15:54 > > I'm wondering how I can, remove the 'Nan' that appears in a matrix ( with "find" I guess)? Not sure what you mean by "remove" but for the matrix M, you can try something like M(isnan(M)) = 0 HTH -- Christophe Dang Ngoc Chan Mechanical calculation engineer Public 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. From paul.carrico at esterline.com Thu Nov 8 16:20:08 2018 From: paul.carrico at esterline.com (Carrico, Paul) Date: Thu, 8 Nov 2018 15:20:08 +0000 Subject: [Scilab-users] How to remove 'Nan' in a matrix In-Reply-To: References: Message-ID: <3A6B7233274DB449A2A0053A47684F953FF02367@BGS-EX01.auxitrol.ad> M(isnan(M)) = [] :-) Thanks Christophe it works fine -----Message d'origine----- De?: users [mailto:users-bounces at lists.scilab.org] De la part de Dang Ngoc Chan, Christophe Envoy??: jeudi 8 novembre 2018 16:04 ??: Users mailing list for Scilab Objet?: [EXTERNAL] Re: [Scilab-users] How to remove 'Nan' in a matrix Hello Paul, > De : users [mailto:users-bounces at lists.scilab.org] De la part de > Carrico, Paul Envoy? : jeudi 8 novembre 2018 15:54 > > I'm wondering how I can, remove the 'Nan' that appears in a matrix ( with "find" I guess)? Not sure what you mean by "remove" but for the matrix M, you can try something like M(isnan(M)) = 0 HTH -- Christophe Dang Ngoc Chan Mechanical calculation engineer Public 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 users at lists.scilab.org https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.scilab.org_mailman_listinfo_users&d=DwIFAw&c=0hKVUfnuoBozYN8UvxPA-w&r=4TCz--8bXfJhZZvIxJAemAJyz7Vfx78XvgYu3LN7eLo&m=5MxZksxnKDdWnigvfYU0vPineJ_MKUtJA04CMbCl-BU&s=PEPq0FNRlHdknIM99pZwt3ax1jO9FxoOeT98mj8DrXE&e= EXPORT CONTROL : Cet email ne contient pas de donn?es techniques This email does not contain technical data From vvp at tu-sofia.bg Thu Nov 8 17:24:07 2018 From: vvp at tu-sofia.bg (Vesela Pasheva) Date: Thu, 08 Nov 2018 18:24:07 +0200 Subject: [Scilab-users] how to stop running scilab Message-ID: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> How to stop running scilab using contro keys (like "ctrl/C") in Mallab? I am using scilab 6.0.1 for Windows 64 bits. Thanks Vesela Pasheva From paul18fr at gmail.com Thu Nov 8 18:34:24 2018 From: paul18fr at gmail.com (paul francedixhuit) Date: Thu, 8 Nov 2018 18:34:24 +0100 Subject: [Scilab-users] how to stop running scilab In-Reply-To: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> References: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> Message-ID: Ctrl+C directly in the console + type abort Le jeu. 8 nov. 2018 ? 17:24, Vesela Pasheva a ?crit : > How to stop running scilab using contro keys (like "ctrl/C") in Mallab? > > I am using scilab 6.0.1 for Windows 64 bits. > > Thanks > Vesela Pasheva > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vvp at tu-sofia.bg Thu Nov 8 19:47:06 2018 From: vvp at tu-sofia.bg (Vesela Pasheva) Date: Thu, 08 Nov 2018 20:47:06 +0200 Subject: [Scilab-users] how to stop running scilab In-Reply-To: References: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> Message-ID: Unfortunatelly it doesn't work. Scilab loses its control and it goes to the Windows. In the scilab program there is a bug that I can not identify because the information on the console goes out. Thank you. Vesela ?? 08-11-2018 19:34, paul francedixhuit ??????: > Ctrl+C directly in the console + type abort > > Le jeu. 8 nov. 2018 ? 17:24, Vesela Pasheva a > ?crit : > >> How to stop running scilab using contro keys (like "ctrl/C") in >> Mallab? >> >> I am using scilab 6.0.1 for Windows 64 bits. >> >> Thanks >> Vesela Pasheva >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> http://lists.scilab.org/mailman/listinfo/users [1] > > > Links: > ------ > [1] http://lists.scilab.org/mailman/listinfo/users > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From stephane.mottelet at utc.fr Thu Nov 8 20:06:27 2018 From: stephane.mottelet at utc.fr (=?utf-8?Q?St=C3=A9phane_Mottelet?=) Date: Thu, 8 Nov 2018 20:06:27 +0100 Subject: [Scilab-users] how to stop running scilab In-Reply-To: References: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> Message-ID: Hello Can you use a try/catch/end around the presumed buggy code ? S. > Le 8 nov. 2018 ? 19:47, Vesela Pasheva a ?crit : > > Unfortunatelly it doesn't work. Scilab loses its control and it goes to the Windows. In the scilab program there is a bug that I can not identify because the information on the console goes out. > > Thank you. > > Vesela > > > ?? 08-11-2018 19:34, paul francedixhuit ??????: >> Ctrl+C directly in the console + type abort >> Le jeu. 8 nov. 2018 ? 17:24, Vesela Pasheva a >> ?crit : >>> How to stop running scilab using contro keys (like "ctrl/C") in >>> Mallab? >>> I am using scilab 6.0.1 for Windows 64 bits. >>> Thanks >>> Vesela Pasheva >>> _______________________________________________ >>> users mailing list >>> users at lists.scilab.org >>> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users [1] >> Links: >> ------ >> [1] https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users > _______________________________________________ > users mailing list > users at lists.scilab.org > https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users From heinznabielek at me.com Thu Nov 8 20:18:32 2018 From: heinznabielek at me.com (Heinz Nabielek) Date: Thu, 08 Nov 2018 20:18:32 +0100 Subject: [Scilab-users] how to stop running scilab In-Reply-To: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> References: <50d99c020ab2751c2b053efbaf8a43a8@tu-sofia.bg> Message-ID: Command+C on the Mac > On 08.11.2018, at 17:24, Vesela Pasheva wrote: > > How to stop running scilab using contro keys (like "ctrl/C") in Mallab? > > I am using scilab 6.0.1 for Windows 64 bits. > > Thanks > Vesela Pasheva > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From heinznabielek at me.com Thu Nov 8 20:24:25 2018 From: heinznabielek at me.com (Heinz Nabielek) Date: Thu, 08 Nov 2018 20:24:25 +0100 Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: <1541621187978-0.post@n3.nabble.com> References: <1541621187978-0.post@n3.nabble.com> Message-ID: Great. Thanks. Should have thought of it myself... Still: is there a vector way? Heinz > On 07.11.2018, at 21:06, kjubo wrote: > > > > Hello, > > precalculate the know values, I gain 40% faster execution time. > Hope helps a bit... > > BR > > clc, clear, mode(0) > > n=1e6 > Z=grand(1,n,'nor',0,1); > Z=Z(:); > r=0.9; > > tic() > V1=Z; > for ii=2:n; > V1(ii)=r*V1(ii-1)+sqrt(1-r^2)*Z(ii); > end; > toc() > > tic() > V2 = Z; > k1 = sqrt(1-r^2).*Z; > for ii=2:n; > V2(ii) = r*V2(ii-1) + k1(ii); > end; > toc() > > isequal(V1,V2) From sgougeon at free.fr Thu Nov 8 21:04:58 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Thu, 8 Nov 2018 21:04:58 +0100 Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: References: <1541621187978-0.post@n3.nabble.com> Message-ID: Le 08/11/2018 ? 20:24, Heinz Nabielek a ?crit : > Great. Thanks. Should have thought of it myself... > > Still: is there a vector way? Didn't you read Guylaine's answer? She proposes a tricky algorithm. Unfortunately, it cannot be used for very long Z input, due to memory considerations. I am afraid that there is no other better "vectorized" solution. This is why a builtin function like filter() -- that aims to do what you want -- is required. BR From heinznabielek at me.com Thu Nov 8 21:34:00 2018 From: heinznabielek at me.com (Heinz Nabielek) Date: Thu, 08 Nov 2018 21:34:00 +0100 Subject: [Scilab-users] vector operation replacing for loop In-Reply-To: References: <1541621187978-0.post@n3.nabble.com> Message-ID: <3FC0DE38-D184-45A1-BFC3-3AFDBA85188C@me.com> Thanks > On 08.11.2018, at 21:04, Samuel Gougeon wrote: > > Le 08/11/2018 ? 20:24, Heinz Nabielek a ?crit : >> Great. Thanks. Should have thought of it myself... >> >> Still: is there a vector way? > > Didn't you read Guylaine's answer? > She proposes a tricky algorithm. Unfortunately, it cannot be used for very long Z input, due to memory considerations. > I am afraid that there is no other better "vectorized" solution. > > This is why a builtin function like filter() -- that aims to do what you want -- is required. > > BR > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From iwoj at il.pw.edu.pl Fri Nov 9 15:03:27 2018 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Fri, 09 Nov 2018 15:03:27 +0100 Subject: [Scilab-users] Suspending x_mdialog Message-ID: <72e34b640354793c2d49553c1beb09fc@il.pw.edu.pl> Hello, I asked this question in a post about something else and nobody answered so I repeat it here. In my code I create a window with figure which is needed to properly choose the values from a listbox which pops up simultaneously.But in the next lines of code I have some x_mdialogs which pop up together with my listbox and block the figure as well as the listbox. How can I suspend the x_mdialogs until I choose values from the list? Do I have to change the x_mdialogs into uicontrols? Kind regards, Iza From amonmayr at laas.fr Fri Nov 9 21:38:54 2018 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Fri, 09 Nov 2018 21:38:54 +0100 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ICBTdXNwZW5kaW5nIHhfbWRp?= =?utf-8?q?alog?= In-Reply-To: <72e34b640354793c2d49553c1beb09fc@il.pw.edu.pl> Message-ID: <3aa6-5be5f080-7-6117ad00@19723346> Le Vendredi, Novembre 09, 2018 15:03 CET, Izabela W?jcik-Grz?ba a ?crit: > Hello, > > I asked this question in a post about something else and nobody answered > so I repeat it here. > In my code I create a window with figure which is needed to properly > choose the values from a listbox which pops up simultaneously.But in the > next lines of code I have some x_mdialogs which pop up together with my > listbox and block the figure as well as the listbox. How can I suspend > the x_mdialogs until I choose values from the list? Do I have to change > the x_mdialogs into uicontrols? yes: x_mdialogs is modal and blocks everything! So you can either mimic the x_mdialogs using another graphic window populated with a bunch of uicontrols or integrate everything in a single window. Antoine > > Kind regards, > Iza > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From moi at moi2.sakura.ne.jp Sat Nov 10 06:45:10 2018 From: moi at moi2.sakura.ne.jp (moi) Date: Sat, 10 Nov 2018 14:45:10 +0900 Subject: [Scilab-users] Something wrong with the conversion from frequency domain to time domain? Message-ID: <53c9860e-470c-bd1f-36d4-bc75d0f9c9cd@moi2.sakura.ne.jp> Hello, I'm trying to convert a function from continuous time to discrete time. There is following continuous time transfer function. Gc = 1 / (1 + 0.1*s) I converted to continuous time state space. Gsl = tf2ss(Gc) and converted to discrete time state space with dt = 0.001 sec. Gsd = dscr(Gsl, 0.001) Finally, converted to discrete time transfer function. Gd = ss2tf(Gsd) The result is following: Gd? = ???? 0.0099502 ?? --------------- ?? -0.9900498 + z I converted these function with the inverse Laplace transform and the inverse z transform. Inverse Laplace transform: L^-1[Gc] = y(t) = 10*e^(-10*t) Inverse Z transform: Apply 'z^-1' to numerator and denominator. Z^-1[Gd] = 0.0099502 * z^-1 / (-0.9900498 * z^-1 + 1) Apply the inverse z transform formula 'L^-1[1/(1 - az)] = a^n * u[n]' and 'L^-1[z^-k * F] = D^k * F'. Z^-1[Gd] = 0.0099502 * D^-1 * 0.9900498^n * u[n]; ??? y[n] = 0.0099502 * 0.9900498^[n-1] * u[n]; I calculated these expressions in Excel. t??? y(t)??????? y[n] 0??? 10????????? 0.0099502 1??? 9.900498337 0.0099502 2??? 9.801986733 0.009851194 3??? 9.704455335 0.009753172 4??? 9.607894392 0.009656126 5??? 9.512294245 0.009560046 6??? 9.417645336 0.009464921 7??? 9.323938199 0.009370744 8??? 9.231163464 0.009277503 9??? 9.139311853 0.00918519 The numerical value is greatly different. Did I mistake something? Thanks in advance. moi From iwoj at il.pw.edu.pl Mon Nov 12 16:15:45 2018 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Mon, 12 Nov 2018 16:15:45 +0100 Subject: [Scilab-users] Vectorfind with accuracy Message-ID: Hello, I am wondering if it is possible to use "vectorfind" function with a given accuracy so it could find equal vectors even when there is a slight difference between their elements. Thank you in advance. Kind regards, Iza From jrafaelbguerra at hotmail.com Mon Nov 12 16:54:28 2018 From: jrafaelbguerra at hotmail.com (Rafael Guerra) Date: Mon, 12 Nov 2018 15:54:28 +0000 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: References: Message-ID: Hi Iza, Why not rounding-off both inputs to the desired accuracy before vectorfind? Regards, Rafael -----Original Message----- From: users On Behalf Of Izabela W?jcik-Grzaba Sent: Monday, November 12, 2018 5:16 PM To: users at lists.scilab.org Subject: [Scilab-users] Vectorfind with accuracy Hello, I am wondering if it is possible to use "vectorfind" function with a given accuracy so it could find equal vectors even when there is a slight difference between their elements. Thank you in advance. Kind regards, Iza _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users From stephane.mottelet at utc.fr Mon Nov 12 17:52:05 2018 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Mon, 12 Nov 2018 17:52:05 +0100 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: References: Message-ID: Le 12/11/2018 ? 16:15, Izabela W?jcik-Grz?ba a ?crit?: > Hello, > > I am wondering if it is possible to use "vectorfind" function with a > given accuracy so it could find equal vectors even when there is a > slight difference between their elements. > > Thank you in advance. > Kind regards, > Iza > _______________________________________________ > users mailing list > users at lists.scilab.org > https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users > Hello, Please find attached a tweaked version of vectorfind with a fourth argument "tol". It can output the following stuff alr=[1,2,2; ???? 1.0001,2,1; ???? 1,1,2; ???? 1,1,1; ???? 1,2,1]; ind = vectorfindtol(alr,[1,2,1],'r',1e-4) ?ind? = ?? 2.?? 5. S. -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) INRIA // Copyright (C) 2010 - DIGITEO - Vincent COUVERT // // Copyright (C) 2012 - 2016 - Scilab Enterprises // // This file is hereby licensed under the terms of the GNU GPL v2.0, // pursuant to article 5.3.4 of the CeCILL v.2.1. // This file was originally licensed under the terms of the CeCILL v2.1, // and continues to be available under such terms. // For more information, see the COPYING file which you should have received // along with this program. function ind=vectorfindtol(m,v,job,tol) rhs = argn(2); // Check number of inputs, at least 2 needed if rhs < 2 then error(msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"), "vectorfind", 2, 3)); end // Set default value for job if not given if rhs < 3 then job = "r"; end if rhs < 4 then tol=0 end // Check that m and v have the same type if typeof(m) <> typeof(v) then error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same type expected.\n"), "vectorfind", 1, 2)); end if min(size(v))<>1 then error(msprintf(gettext("%s: Wrong size for input argument #%d: Vector expected.\n"),"vectorfind",2)); end if convstr(part(job,1))=="r" then if size(v,"*")<>size(m,2) then error(msprintf(gettext("%s: Wrong size for input arguments: Incompatible sizes.\n"),"vectorfind")); end ind=1:size(m,1) for k=1:size(m,2) ind=ind(find(abs(m(ind,k)-v(k))<=tol)); if ind==[] then break end end elseif convstr(part(job,1))=="c" then if size(v,"*")<>size(m,1) then error(msprintf(gettext("%s: Wrong size for input arguments: Incompatible sizes.\n"),"vectorfind")); end ind=1:size(m,2) for k=1:size(m,1) ind=ind(find(abs(m(k,ind)-v(k))<=tol)) if ind==[] then break end end else error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'' or ''%s'' expected.\n"),"vectorfind",3,"r[ow]","c[olumn]")); end endfunction From heinznabielek at me.com Mon Nov 12 23:57:08 2018 From: heinznabielek at me.com (Heinz Nabielek) Date: Mon, 12 Nov 2018 23:57:08 +0100 Subject: [Scilab-users] filter(): How to use the last zi argument <= Re: vector operation replacing for loop In-Reply-To: <035faa35-62d4-d43c-eec0-4eb0aef2e8be@free.fr> References: <80d2cb85-40b9-2304-84c3-7b686139dc9e@free.fr> <035faa35-62d4-d43c-eec0-4eb0aef2e8be@free.fr> Message-ID: On 07.11.2018, at 20:57, Samuel Gougeon wrote: > > Hello, > > Is there anyone here that uses to use the last filter() optional argument? > > In the example of the thread reminded below: > V = Z; > for i=2:n > V(i) = a*V(i-1) + b*Z(i); > end In my case, a^2 + b^2 =1, if that should make any difference? Has the problem been sorted out, how to use "filter"? Heinz > the input is Z, the output is V, a and b are fixed parameters. > The filter() description tells: > >> Syntax >> ------ >> [y,zf] = filter(B, A, x [,zi]) >> >> Parameters >> ---------- >> B : real vector : the coefficients of the filter numerator in decreasing power order, or >> a polynomial. >> A : real vector : the coefficients of the filter denominator in decreasing power order, >> or a polynomial. >> x : real row vector : the input signal >> zi : real row vector of length max(length(a),length(b))-1: the initial condition >> relative to a "direct form II transposed" state space representation. The default >> value is a vector filled with zeros. > > So here i assume that zi is V(0) (so actually Z(1)). Then, how to get > [Z(1) V(2:n)] > as from the above loop? I have tried the following, without success: > y = filter(b, [1 -a], Z); > or > y = [Z(1) filter(b, [1 -a], Z(2:$), Z(1))]; > or > y = filter(b, [1 -a], Z, Z(1)*(1-b)/a); > > The zi option has no example, and unless filter() is bugged, the way zi works/is taken into account is unclear. > > Any hint (before analyzing its hard code..)? > > Regards > Samuel > > > Le 01/11/2018 ? 15:16, Samuel Gougeon a ?crit : >> Le 01/11/2018 ? 13:40, Samuel Gougeon a ?crit : >>> Hello, >>> >>> Le 01/11/2018 ? 09:27, Heinz Nabielek a ?crit : >>>> Sorry, Scilab friends, I am still not fluid with vector operations. >>>> Can someone rewrite the for loop for me into something much more efficient? >>>> >>>> n=1000; >>>> Z=grand(1,n,'nor',0,1); >>>> r=0.9; >>>> V=Z; >>>> for i=2:n; >>>> V(i)=r*V(i-1)+sqrt(1-r^2)*Z(i); >>>> end; >>>> >>>> The transformation generates an autocorrelated (here rho=0.9) normal distribution V from an uncorrelated normal distribution Z and eventually I will need it for very much larger n values.... >>>> >>> >>> You may use filter(), with a feedback component (since V(i) depends on the previous state V(i-1) computed at the previous step). >>> However, as shown below, a quick trial shows an initial discrepancy between filter() result and yours with the explicit loop. >>> I don't know why. May be the setting for the initial condition should be carefully considered/tuned... >> >> This is certainly the reason. For i=1, V(i-1) is unknown and must be somewhat provided. The last filter() option zi is not really documented (i have no time to go to the reference to get clear about how "the initial condition relative to a "direct form II transposed" state space representation." works. Trying to provide a value V(0) such that V(1)==Z(1) decreases the initial discrepancy by a factor 10. But it is still non zero. >> y = filter(sqrt(1-r^2), [1 -r], Z, Z(1)*(1-sqrt(1-r^2))/r); >> >> >> >> _______________________________________________ >> users mailing list >> >> users at lists.scilab.org >> http://lists.scilab.org/mailman/listinfo/users > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From sgougeon at free.fr Tue Nov 13 01:11:40 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Tue, 13 Nov 2018 01:11:40 +0100 Subject: [Scilab-users] filter(): How to use the last zi argument <= Re: vector operation replacing for loop In-Reply-To: References: <80d2cb85-40b9-2304-84c3-7b686139dc9e@free.fr> <035faa35-62d4-d43c-eec0-4eb0aef2e8be@free.fr> Message-ID: Le 12/11/2018 ? 23:57, Heinz Nabielek a ?crit : > On 07.11.2018, at 20:57, Samuel Gougeon wrote: >> Hello, >> >> Is there anyone here that uses to use the last filter() optional argument? >> >> In the example of the thread reminded below: >> V = Z; >> for i=2:n >> V(i) = a*V(i-1) + b*Z(i); >> end > > In my case, a^2 + b^2 =1, if that should make any difference? It does not. > Has the problem been sorted out, how to use "filter"? It hasn't been clarified. We likely must go in the code to see what it does... and document the option. From iwoj at il.pw.edu.pl Tue Nov 13 12:50:22 2018 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Tue, 13 Nov 2018 12:50:22 +0100 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: References: Message-ID: Hello, Thanks, it looks like it's exactly what I need but it doesn't work in version 6.0.1. What should I do to implement it? Iza W dniu 12.11.2018 17:52, St?phane Mottelet napisa?(a): > Le 12/11/2018 ? 16:15, Izabela W?jcik-Grz?ba a ?crit?: >> Hello, >> >> I am wondering if it is possible to use "vectorfind" function with a >> given accuracy so it could find equal vectors even when there is a >> slight difference between their elements. >> >> Thank you in advance. >> Kind regards, >> Iza >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users > > Hello, > > > Please find attached a tweaked version of vectorfind with a fourth > argument "tol". It can output the following stuff > > alr=[1,2,2; > ???? 1.0001,2,1; > ???? 1,1,2; > ???? 1,1,1; > ???? 1,2,1]; > > ind = vectorfindtol(alr,[1,2,1],'r',1e-4) > > ?ind? = > > ?? 2.?? 5. > > S. > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From iwoj at il.pw.edu.pl Tue Nov 13 16:42:29 2018 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Tue, 13 Nov 2018 16:42:29 +0100 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: References: Message-ID: <8c5a7abed982aa5fe20bdb4736615833@il.pw.edu.pl> Thank you St?phane and please ignore my last post - I didn't see the attachement at first. I wanted to put your function to the library and have it loaded at startup of each session. I used the function: genlib ("Moja_biblioteka","C:/Program Files/mojabiblioteka_scilab") and created a scilab.ini file in SCIHOME in which I put a line: Moja_biblioteka = lib("C:/Program Files/mojabiblioteka_scilab") Now your function vectorfindtol works only for the first time after starting Scilab and only in the console. When I want to use it in a .sce file it doesn't work at all. I get the message: "Undefined variable: vectorfindtol". Am I doing something wrong or did I miss something? Thanks, Iza W dniu 12.11.2018 17:52, St?phane Mottelet napisa?(a): > Le 12/11/2018 ? 16:15, Izabela W?jcik-Grz?ba a ?crit?: >> Hello, >> >> I am wondering if it is possible to use "vectorfind" function with a >> given accuracy so it could find equal vectors even when there is a >> slight difference between their elements. >> >> Thank you in advance. >> Kind regards, >> Iza >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users > > Hello, > > > Please find attached a tweaked version of vectorfind with a fourth > argument "tol". It can output the following stuff > > alr=[1,2,2; > ???? 1.0001,2,1; > ???? 1,1,2; > ???? 1,1,1; > ???? 1,2,1]; > > ind = vectorfindtol(alr,[1,2,1],'r',1e-4) > > ?ind? = > > ?? 2.?? 5. > > S. > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From sgougeon at free.fr Tue Nov 13 23:12:01 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Tue, 13 Nov 2018 23:12:01 +0100 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: <8c5a7abed982aa5fe20bdb4736615833@il.pw.edu.pl> References: <8c5a7abed982aa5fe20bdb4736615833@il.pw.edu.pl> Message-ID: <029f6147-df87-4e82-0c28-cb70b47d5762@free.fr> Le 13/11/2018 ? 16:42, Izabela W?jcik-Grz?ba a ?crit : > Thank you St?phane and please ignore my last post - I didn't see the > attachement at first. > I wanted to put your function to the library and have it loaded at > startup of each session. I used the function: > > genlib ("Moja_biblioteka","C:/Program Files/mojabiblioteka_scilab") > > and created a scilab.ini file in SCIHOME in which I put a line: > > Moja_biblioteka = lib("C:/Program Files/mojabiblioteka_scilab") > > Now your function vectorfindtol works only for the first time after > starting Scilab and only in the console. When I want to use it in a > .sce file it doesn't work at all. I get the message: "Undefined > variable: vectorfindtol". > > Am I doing something wrong or did I miss something? Likely a "clear" instruction at the beginning of your script. This is a Matlabers habit. And just an atomic bomb for Scilab. It deletes all what is deletable around, including users functions, users libraries not autoloaded, etc. Samuel From iwoj at il.pw.edu.pl Wed Nov 14 15:07:06 2018 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Wed, 14 Nov 2018 15:07:06 +0100 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: <029f6147-df87-4e82-0c28-cb70b47d5762@free.fr> References: <8c5a7abed982aa5fe20bdb4736615833@il.pw.edu.pl> <029f6147-df87-4e82-0c28-cb70b47d5762@free.fr> Message-ID: Thanks Samuel, you are right. I use "clear" because while testing my programmes I have to use different values of variables and sometimes it's difficult to find an error in the code especially when some of variables have old values. There are a lot of different variables in my codes so it would be hard to list them. Is there any other way to do it? Iza W dniu 13.11.2018 23:12, Samuel Gougeon napisa?(a): > Le 13/11/2018 ? 16:42, Izabela W?jcik-Grz?ba a ?crit : >> Thank you St?phane and please ignore my last post - I didn't see the >> attachement at first. >> I wanted to put your function to the library and have it loaded at >> startup of each session. I used the function: >> >> genlib ("Moja_biblioteka","C:/Program Files/mojabiblioteka_scilab") >> >> and created a scilab.ini file in SCIHOME in which I put a line: >> >> Moja_biblioteka = lib("C:/Program Files/mojabiblioteka_scilab") >> >> Now your function vectorfindtol works only for the first time after >> starting Scilab and only in the console. When I want to use it in a >> .sce file it doesn't work at all. I get the message: "Undefined >> variable: vectorfindtol". >> >> Am I doing something wrong or did I miss something? > > Likely a "clear" instruction at the beginning of your script. > This is a Matlabers habit. And just an atomic bomb for Scilab. It > deletes all what is deletable around, including users functions, users > libraries not autoloaded, etc. > > Samuel > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From sgougeon at free.fr Thu Nov 15 20:58:37 2018 From: sgougeon at free.fr (Samuel Gougeon) Date: Thu, 15 Nov 2018 20:58:37 +0100 Subject: [Scilab-users] Vectorfind with accuracy In-Reply-To: References: <8c5a7abed982aa5fe20bdb4736615833@il.pw.edu.pl> <029f6147-df87-4e82-0c28-cb70b47d5762@free.fr> Message-ID: Hello Izabela, Le 14/11/2018 ? 15:07, Izabela W?jcik-Grz?ba a ?crit : > Thanks Samuel, you are right. I use "clear" because while testing my > programmes I have to use different values of variables and sometimes > it's difficult to find an error in the code especially when some of > variables have old values. There are a lot of different variables in > my codes so it would be hard to list them. Is there any other way to > do it? You may put less code in your main script, and build and put more code in functions. functions are also useful to isolate some pieces of code and their internal environment, from the calling level. When leaving a function, all internal variables are automatically forgotten. This might help a lot in building complex and reliable programs/computations. Best regards Samuel