From fmiyara at fceia.unr.edu.ar Thu Apr 2 10:27:14 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Thu, 2 Apr 2020 05:27:14 -0300 Subject: [Scilab-users] Polynomial fitting Message-ID: <208747ef-5ed7-4d7f-3883-391c60c2a804@fceia.unr.edu.ar> Dear All, Trying to convert an old Matlab script to Scilab I miss the function polyfit, which computes the coefficients of a polynomial that fits x-y data using the least square method. I found the following thread http://mailinglists.scilab.org/Polynomic-regression-td4030799.html explaining that one can use the backslash, for instance for a 3rd degree polynomial, where x and y are column vectors: X = [ones(x), x, x.^2, x.^3] A = X\y; (I changed the order of powers to get the coefficients ready for horner) I implemented a polyfit function using the basic theory of polynomial regression and I find it is faster by a factor of 1.5-2 than the previously mentioned method. The basic algorithm I use is (n = desired degree): // Initialize matrix X X = ones(length(x), n+1); // Compute Vandermonde's matrix for k =2:n+1 ?? X(:,k) = X(:,k-1).*x; end // Apply the Moore-Penrose pseudoinverse matrix and // multiply by the dependent data vector to get the // least squares approximation of the polynomial // coefficients A = inv(X'*X)*X'*y; I've seen some discussion regarding the need for a polyfit function in Scilab. The main argument against such a function is that it is unnecessary since it is a particular case of the backslash division. This is true, but the above example shows that users' implementations are not always optimized, and as it is such a frequent problem, it would be nice to have a native polyfit (or whatever it may be called) function. Regards, Federico Miyara -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Thu Apr 2 10:48:07 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 2 Apr 2020 10:48:07 +0200 Subject: [Scilab-users] Polynomial fitting In-Reply-To: <208747ef-5ed7-4d7f-3883-391c60c2a804@fceia.unr.edu.ar> References: <208747ef-5ed7-4d7f-3883-391c60c2a804@fceia.unr.edu.ar> Message-ID: <0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr> Hello Frederico, Le 02/04/2020 ? 10:27, Federico Miyara a ?crit?: > > Dear All, > > Trying to convert an old Matlab script to Scilab I miss the function > polyfit, which computes the coefficients of a polynomial that fits x-y > data using the least square method. > > I found the following thread > http://mailinglists.scilab.org/Polynomic-regression-td4030799.html > > explaining that one can use the backslash, for instance for a 3rd > degree polynomial, where x and y are column vectors: > > X = [ones(x), x, x.^2, x.^3] > A = X\y; > > (I changed the order of powers to get the coefficients ready for horner) > > I implemented a polyfit function using the basic theory of polynomial > regression and I find it is faster by a factor of 1.5-2 than the > previously mentioned method. Yeah, but really badly conditionned compared to the above method which is based on orthogonal tranformations (X=Q*R factorization). With your below method you solve a linear system with X'*X matrix which has a condition number which is the square of the condition number of the R matrix issued from the Q*R factorization of X. S. > > The basic algorithm I use is (n = desired degree): > > // Initialize matrix X > X = ones(length(x), n+1); > // Compute Vandermonde's matrix > for k =2:n+1 > ?? X(:,k) = X(:,k-1).*x; > end > // Apply the Moore-Penrose pseudoinverse matrix and > // multiply by the dependent data vector to get the > // least squares approximation of the polynomial > // coefficients > A = inv(X'*X)*X'*y; > > I've seen some discussion regarding the need for a polyfit function in > Scilab. The main argument against such a function is that it is > unnecessary since it is a particular case of the backslash division. > This is true, but the above example shows that users' implementations > are not always optimized, and as it is such a frequent problem, it > would be nice to have a native polyfit (or whatever it may be called) > function. > > Regards, > > Federico Miyara > > _______________________________________________ > 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 Clement.David at esi-group.com Thu Apr 2 12:06:09 2020 From: Clement.David at esi-group.com (=?utf-8?B?Q2zDqW1lbnQgRGF2aWQ=?=) Date: Thu, 2 Apr 2020 10:06:09 +0000 Subject: [Scilab-users] Polynomial fitting In-Reply-To: <0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr> References: <208747ef-5ed7-4d7f-3883-391c60c2a804@fceia.unr.edu.ar> <0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr> Message-ID: Hello Frederico, AFAIK there is a moc_polyfit function inside the Matlab/Octave Compatibility toolbox which might help you porting your code. Stixbox also provides a polyfit function which might be more generic toward Scilab datatypes. Thanks, -- Cl?ment > -----Original Message----- > From: users On Behalf Of St?phane Mottelet > Sent: Thursday, April 2, 2020 10:48 AM > To: users at lists.scilab.org > Subject: Re: [Scilab-users] Polynomial fitting > > Hello Frederico, > > > Le 02/04/2020 ? 10:27, Federico Miyara a ?crit : > > > > Dear All, > > Trying to convert an old Matlab script to Scilab I miss the function > polyfit, which computes the coefficients of a polynomial that fits x-y data using > the least square method. > > I found the following thread http://mailinglists.scilab.org/Polynomic- > regression-td4030799.html > inglists.scilab.org/Polynomic-regression-td4030799.html> explaining that one > can use the backslash, for instance for a 3rd degree polynomial, where x and y > are column vectors: > > X = [ones(x), x, x.^2, x.^3] > A = X\y; > > (I changed the order of powers to get the coefficients ready for horner) > > I implemented a polyfit function using the basic theory of polynomial > regression and I find it is faster by a factor of 1.5-2 than the previously > mentioned method. > > > Yeah, but really badly conditionned compared to the above method which is > based on orthogonal tranformations (X=Q*R factorization). With your below > method you solve a linear system with X'*X matrix which has a condition number > which is the square of the condition number of the R matrix issued from the Q*R > factorization of X. > > S. > > > > The basic algorithm I use is (n = desired degree): > > // Initialize matrix X > X = ones(length(x), n+1); > // Compute Vandermonde's matrix > for k =2:n+1 > X(:,k) = X(:,k-1).*x; > end > // Apply the Moore-Penrose pseudoinverse matrix and > // multiply by the dependent data vector to get the > // least squares approximation of the polynomial > // coefficients > A = inv(X'*X)*X'*y; > > I've seen some discussion regarding the need for a polyfit function in > Scilab. The main argument against such a function is that it is unnecessary since > it is a particular case of the backslash division. This is true, but the above > example shows that users' implementations are not always optimized, and as it > is such a frequent problem, it would be nice to have a native polyfit (or whatever > it may be called) function. > > Regards, > > Federico Miyara > > > _______________________________________________ > users mailing list > users at lists.scilab.org > https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLm > Zy/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 From fmiyara at fceia.unr.edu.ar Sat Apr 4 09:11:49 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Sat, 4 Apr 2020 04:11:49 -0300 Subject: [Scilab-users] Polynomial fitting In-Reply-To: <0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr> References: <208747ef-5ed7-4d7f-3883-391c60c2a804@fceia.unr.edu.ar> <0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr> Message-ID: St?phane, > Yeah, but really badly conditionned compared to the above method which > is based on orthogonal tranformations (X=Q*R factorization). With your > below method you solve a linear system with X'*X matrix which has a > condition number which is the square of the condition number of the R > matrix issued from the Q*R factorization of X. Thanks for the clarification! Is it posible to predict in what kind of cases will the bad conditioning impact on the result? I've compared the results for several cases and they are exactly the same. However, I've noticed that when taking the inverse of a matrix whose components span several orders of magnitude there are important errors, but if I manage to normalize the poblem the errors are substantially reduced Regards, Federico > S. > >> >> The basic algorithm I use is (n = desired degree): >> >> // Initialize matrix X >> X = ones(length(x), n+1); >> // Compute Vandermonde's matrix >> for k =2:n+1 >> ?? X(:,k) = X(:,k-1).*x; >> end >> // Apply the Moore-Penrose pseudoinverse matrix and >> // multiply by the dependent data vector to get the >> // least squares approximation of the polynomial >> // coefficients >> A = inv(X'*X)*X'*y; >> >> I've seen some discussion regarding the need for a polyfit function >> in Scilab. The main argument against such a function is that it is >> unnecessary since it is a particular case of the backslash division. >> This is true, but the above example shows that users' implementations >> are not always optimized, and as it is such a frequent problem, it >> would be nice to have a native polyfit (or whatever it may be called) >> function. >> >> Regards, >> >> Federico Miyara >> >> _______________________________________________ >> 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 > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmiyara at fceia.unr.edu.ar Sat Apr 4 09:26:07 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Sat, 4 Apr 2020 04:26:07 -0300 Subject: [Scilab-users] question non datafit Message-ID: Dear All, I'm trying to understand the function datafit. The documentation says: datafit is used for fitting data to a model. For a given function G(p,z), this function finds the best vector of parameters p for approximating G(p,z_i)=0 for a set of measurement vectors z_i. Vector p is found by minimizing G(p,z_1)'WG(p,z_1)+G(p,z_2)'WG(p,z_2)+...+G(p,z_n)'WG(p,z_n) I don't quite understand what is G(p,z_1)'WG(p,z_1). Are some product signs * missing? Shouldn't it be G(p,z_1)'*W*G(p,z_1)? Are these signs implied as in regular algebra notation? Thanks, Federioo Miyara || -------------- next part -------------- An HTML attachment was scrubbed... URL: From sgougeon at free.fr Sat Apr 4 11:58:30 2020 From: sgougeon at free.fr (Samuel Gougeon) Date: Sat, 4 Apr 2020 11:58:30 +0200 Subject: [Scilab-users] question non datafit In-Reply-To: References: Message-ID: <528dc3ab-5c8d-cab1-a47d-cbaa73af95d8@free.fr> Le 04/04/2020 ? 09:26, Federico Miyara a ?crit?: > > Dear All, > > I'm trying to understand the function datafit. > > The documentation says: > > datafit is used for fitting data to a model. For a given function > G(p,z), this function finds the best vector of parameters p for > approximating G(p,z_i)=0 for a set of measurement vectors z_i. > Vector p is found by minimizing > G(p,z_1)'WG(p,z_1)+G(p,z_2)'WG(p,z_2)+...+G(p,z_n)'WG(p,z_n) > > > I don't quite understand what is G(p,z_1)'WG(p,z_1). Are some product > signs * missing? Shouldn't it be G(p,z_1)'*W*G(p,z_1)? Are these signs > implied as in regular algebra notation? Hello Federico, Please see the documentation of the /latest/ scilab release: https://help.scilab.org/docs/6.1.0/en_US/datafit.html Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From heinznabielek at me.com Sat Apr 4 15:13:05 2020 From: heinznabielek at me.com (Heinz Nabielek) Date: Sat, 4 Apr 2020 15:13:05 +0200 Subject: [Scilab-users] Error in parameters determined in non-linear least-squares fitting Message-ID: Scilab friends: the power of Scilab is amazing and I have used it recently for non-linear least-squares fitting, below example from Scilab help function for "datafit". On occasions, I have also used "leastsq". Question: how do I derive the 1sigma standard error in the three parameters p(1), p(2), and p(3)? And, if it is not too complicated, covariances? I know this is written in dozens of textbooks, but I am always getting lost. Please provide a simple recipe written in Scilab. Best greetings Heinz // -- 04/04/2020 14:57:30 -- // //generate the data function y=FF(x, p) y=p(1)*(x-p(2))+p(3)*x.*x endfunction X=[]; Y=[]; pg=[34;12;14] //parameter used to generate data for x=0:.1:3 Y=[Y,FF(x,pg)+100*(rand()-.5)]; X=[X,x]; end Z=[Y;X]; //The criterion function function e=G(p, z), y=z(1),x=z(2); e=y-FF(x,p), endfunction //Solve the problem p0=[3;5;10] [p,err]=datafit(G,Z,p0); scf(0);clf() plot2d(X,FF(X,pg),5) //the curve without noise plot2d(X,Y,-1) // the noisy data plot2d(X,FF(X,p),12) //the solution xgrid();legend("the curve without noise"," the noisy data", "THE FINAL SOLUTION.....",4); title("solution set 39.868419 10.312053 11.482521","fontsize",4); -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-2.tiff Type: image/tiff Size: 39064 bytes Desc: not available URL: From stephane.mottelet at utc.fr Sat Apr 4 17:00:12 2020 From: stephane.mottelet at utc.fr (stephane.mottelet at utc.fr) Date: Sat, 04 Apr 2020 17:00:12 +0200 Subject: [Scilab-users] Error in parameters determined in non-linear least-squares fitting In-Reply-To: Message-ID: <20200404170012.Horde.6p62YbLWPJ1x4gXWmzBn849@webmail.utc.fr> Hello Heinz, You can have a look at pages 45-49 of my slides on least Squares : http://www.utc.fr/~mottelet/mt94/leastSquares.pdf Page 48 you have an example where the Covariance matrix is approximated for a fitting problem with an ode defined page 42. S. Quoting Heinz Nabielek : > Scilab friends: the power of Scilab is amazing and I have used it > recently for non-linear least-squares fitting, below example from > Scilab help function for "datafit". On occasions, I have also used > "leastsq". > ? > Question: how do I derive the 1sigma standard error in the three > parameters p(1), p(2), and p(3)? And, if it is not too complicated, > covariances? > ? > I know this is written in dozens of textbooks, but I am always > getting lost. > Please provide a simple recipe written in Scilab. > Best greetings > Heinz > ? > ? > ? > // -- 04/04/2020 14:57:30 -- ////generate the datafunction y=FF(x, > p) y=p(1)*(x-p(2))+p(3)*x.*xendfunctionX=[]; Y=[]; pg=[34;12;14] > //parameter used to generate datafor x=0:.1:3 > Y=[Y,FF(x,pg)+100*(rand()-.5)]; X=[X,x]; endZ=[Y;X]; //The > criterion functionfunction e=G(p, z), y=z(1),x=z(2); > e=y-FF(x,p), endfunction//Solve the > problemp0=[3;5;10][p,err]=datafit(G,Z,p0); > scf(0);clf()plot2d(X,FF(X,pg),5) //the curve without > noiseplot2d(X,Y,-1) // the noisy dataplot2d(X,FF(X,p),12) //the > solutionxgrid();legend("the curve without noise"," the noisy data", > "THE FINAL SOLUTION.....",4); title("solution set 39.868419 > 10.312053 11.482521","fontsize",4); -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-2.tiff Type: image/tiff Size: 39064 bytes Desc: not available URL: From amonmayr at laas.fr Mon Apr 6 08:17:36 2020 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Mon, 06 Apr 2020 08:17:36 +0200 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ICBFcnJvciBpbiBwYXJhbWV0?= =?utf-8?q?ers_determined_in_non-linear_least-squares_fitting?= In-Reply-To: Message-ID: Hello Heinz, See below the small example I built and I refer to whenever I need to do some data fitting with confidence intervals for the parameters of the model. It is far from perfect but it might help you untangle the Jacobian and covariance matrix thingy. Just two words of caution: (1) I am clearly less versed in applied maths than St?phane or Samuel, so take this with a grain of salft; (2) I built this example ages ago, before Samuel improved datafit. Good luck Antoine ////////////////////////////////////////////////////////////////////////////////////// // REFERENCE: // // Least Squares Estimation // SARA A. VAN DE GEER // Volume 2, pp. 1041?1045 // in // Encyclopedia of Statistics in Behavioral Science // ISBN-13: 978-0-470-86080-9 // ISBN-10: 0-470-86080-4 // Editors Brian S. Everitt & David C. Howell // John Wiley & Sons, Ltd, Chichester, 2005 // //This is a short and definetly incomplete tutorial on data fitting in Scilab using leastsq. // // Basic assumption: this tutorial is for scientists that face this simple problem: // they have an experimental dataset x_epx,y_exp and a certain model y=Model(x,p) to fit thie dataset. // This tutorial will try to answer the folowing questions: // 1) how do you do that (simply) // 2) how do you do that (more reliably and more quickly) // a) let's go faster with a Jacobian // b) how good is your fit? How big is the "error bar" associated with each parameter of your Model? // c) Can we bullet proof it? //1) How do you do curve fitting in Scilab // // We need a) a model function b) a dataset c) some more work // 1)a) Let's start with the model function: a sinewave // here is the formula: y=A*sin(k*(x-x0))+y0; // here is the function prototypr [y]=SineModel(x,p) with p=[x0,k,A,y0]' function [y]=SineModel(x,p) //INPUTS: x 1D vector // p parameter vector of size [4,1] containing // x0 : sine origin // k : sine spatial frequency ie k=2%pi/Xp with Xp the period // A : sine amplitude // y0 : sine offset //OUTPUTS: y 1D vector of same size than x such that y=A*sin(k*(x-x0))+y0; x0=p(1); k=p(2); A=p(3); y0=p(4); y=y0+A*sin((x-x0)*k); endfunction // 1)b) Let's now have a fake dataset: a sine wave with some noise // We reuse the Model function we have just created to make this fake dataset x_exp=[-10:0.1:10]'; x0=1.55; k=1*%pi/3; A=4.3; y0=1.1 y_exp=SineModel(x_exp,[x0,k,A,y0])+(2*rand(x_exp)-1)*6/10; //let's check and see what it looks like: scf(); plot(x_exp,y_exp,'k.-'); xlabel('Exparimental X'); ylabel('Exparimental Y'); xtitle('Our fake experimental dataset to fit'); // 1)c) we are not done yet, we need some more work // First we need an error function that return for a given parameter set param the difference // between the experimental dataset and the model one: // Note that this function returns the difference at each point, not the square of the difference, // nor the sum over each point of the square of the differences function e = ErrorFitSine(param, x_exp, y_exp) e = SineModel(x_exp,param)-y_exp; endfunction // Now we need a starting point that is not too far away from the solution // Let's just fo it by hand for the moment we'll see later how to make it programmatically // Just go and have a look at the previous plot and "guess", here is mine: p0=[1,2*%pi/6,4,1]; //Ready to go: [f,popt, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); //popt contains the optimal parameter set that fits our dataset // scf(); plot(x_exp,y_exp,'k.'); plot(x_exp,SineModel(x_exp,popt),'r-'); xlabel('Experimental X') ylabel('Experimental Y and best fit'); xtitle([... "x0="+msprintf('%1.3f fit value: \t%1.3f',x0,popt(1));... "k ="+msprintf('%1.3f fit value: \t%1.3f',k,popt(2));... "A ="+msprintf('%1.3f fit value: \t%1.3f',A,popt(3));... "y0="+msprintf('%1.3f fit value: \t%1.3f',y0,popt(4))... ]); //Yep we are done popt is the optimal parameter set that fits our dataset x_exp,y_exp with our // model SineModel // How to assert the quality of our fit? We can use fopt and gropt for that. They should be both as small as possible. // Ideally, the gradient should be zeros for each parameter, otherwise it means we have not found an optimum. //2) How to go beyond that simple example? // Namely: // a) how to go faster? // b) how to estimate how good our fit is (aka get error bars on our parameters)? // c) how to make thinks more reliable with less human guessing and more bulletproofing? //2)a) and also 2)b) // We need the same extra function in order to speed things up and to estimate // how the "noise" on the experimental dataset translates in "noise" on each // individual parameter p(1), ...p($): the Jacobian matrix of our fit model. // Impressive name for a simple idea: providing leastsq with the partial // derivative of the model formula with respect to each parameter p(1)..p($). function g = ErrorJMatSine(p, x, y) // // g(1,:) = d(SinModel(x,p))/dx0 = d(SinModel(x,p))/d(p(1)) // g(2,:) = d(SinModel(x,p))/dk = d(SinModel(x,p))/d(p(2)) // g(3,:) = d(SinModel(x,p))/dA = d(SinModel(x,p))/d(p(3)) // g(4,:) = d(SinModel(x,p))/dy0 = d(SinModel(x,p))/d(p(4)) // y=A*sin(k*(x-x0))+y0; x0=p(1); k=p(2); A=p(3); y0=p(4); g = [... (-k)*SineModel(x,[x0-%pi/2/k,k,A,0]'),... (x-x0).*SineModel(x,[x0-%pi/2/k,k,A,0]'),... SineModel(x,[x0,k,1,0]'),... ones(x) ... ]; endfunction //Ready to go again, and faster this time: [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); disp("This should be ~ [0,0,0] when both fits give exactly the same results") disp(string((popt-popt_fast)./(popt+popt_fast))) //Now we check that we are faster: // we do it several times to average over timing variations caused by // other processes running on our computer speedup=zeros(1,10) for i=1:100 tic(); [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); t1=toc(); tic(); [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); t2=toc(); speedup(i)=t1/t2; end scf(); plot(speedup,'k.'); plot(mean(speedup)*ones(speedup),'r'); xlabel("Fit iteration"); ylabel("SpeedUp factor when using Jacobian Matrix"); xtitle("Here we have a "+msprintf("~%1.2f",mean(speedup))+... " speed improvement using the Jacobian Matrix"); //2)b) How can we estimate "error bars" for each individual parameters? // We are going to estimate how the "noise" on our dataset turns into // noise on each parameter by estimating the confidence interval at 95% g = ErrorJMatSine(popt_fast, x_exp, y_exp);//Jacobian matrix of the fit formula //estimate of the initial noise on the dataset to fit sigma2=1/(length(x_exp)-length(popt_fast))*f; //covariance matrix of fitting parameters pcovar=inv(g'*g)*sigma2; //confidence interval for each parameter ci=(1.96*sqrt(diag(pcovar)))'; //Let's present the results of the confidence interval calculation str=msprintf("%4.3f\n", popt_fast')+' +/- '+msprintf("%4.3f\n", ci'); str=[["x0 = ";"k = ";"A = ";"y0 = "]+str]; str=["Fit results:";"y=A*sin(k*(x-x0))+y0";"Param +/- conf. interval @ 95%";str] scf(); plot(x_exp,y_exp,'k.'); plot(x_exp,SineModel(x_exp,popt_fast),'r-'); xlabel('Experimental X') ylabel('Experimental Y and best fit'); xtitle('Fit with confidence intervals at 95%'); xstringb(-6,-3,str,12,6,'fill'); e=gce(); e.box="on"; e.fill_mode="on"; e.background=color("light gray"); //Now we have a fast fit function that can give some estimation on // how seriously we can believe the fitted parameters. // You can see that the precision with which we retrieve each parameter varies // k0 is more precisely determined than y0 (15x more precisely!) //You can play with the amount of noise to see how it affects the retrieved // parameters and confidence intervals //2)b) How can we bullet proof our fitting script by putting all this stuff // together is several functions that checks the arguments and modify // them if needed to avoid difficult to understand complaints from // leastsq? // test of a sinus fitting routine //// y=A*sin(k*(x-x0))+y0; //// function [y]=Sine(x,x0,k,A,y0) //// function [y]=Sine(x,p) with p=[x0,k,A,y0]' //function [y]=Sine(x,varargin) //// pause // select length(varargin) // case 1 then // //we use form [y]=Sine(x,p) where p=[x0,dx,A,y0]' // p=varargin(1); // case 4 then // //we use form [y]=Sine(x,x0,k,A,y0) // p=[varargin(1);varargin(2);varargin(3);varargin(4)]; // else // //call is not correct, we give up // y=[];return // end // x0=p(1); // k=p(2); // A=p(3); // y0=p(4); // y=y0+A*sin((x-x0)*k); //endfunction // function [p0,pinf,psup]=EstimateFitSine(x,y) // y=A*sin(k*(x-x0))+y0; y0=mean(y); A=(max(y)-min(y))/2; // pause sy=fftshift(fft(y-mean(y))); //sy=fft(y-mean(y)); msy=max(abs(sy));rg=find(abs(sy)==msy); delta=(rg(2)-rg(1))/length(y); k=delta*%pi/(mean(diff(x))); x0=mean(abs(atan(imag(sy(rg)),real(sy(rg)))/k))+%pi/2/k; p0=[x0,k,A,y0]; pinf=[min(x),0 ,-%inf ,-%inf]; psup=[max(x),%inf ,%inf ,%inf]; endfunction function e = ErrorFitSine(param, xi, yi) e = SineModel(xi,param)-yi; endfunction function g = dErrorFitSine(param, xi, yi) // y=A*sin(k*(x-x0))+y0; x0=param(1); k=param(2); A=param(3); y0=param(4); // pause g = [... (-k)*SineModel(xi,[x0-%pi/2/k,k,A,0]),... (xi-x0).*SineModel(xi,[x0-%pi/2/k,k,A,0]),... SineModel(xi,[x0,k,1,0]),... ones(xi) ... ]; endfunction function [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0,varargin) // FIT Experimental dataset y(x) with a sine model // [y]=A*sin(k*(x-x0))+y0; // //INPUTS: //x : experiemental x dataset //y : experimental y dataset //p0 : starting parameter set [x0,k,A,y0] //varargin : // pinf inferior limit for popt // psup superior limit for popt //OUTPUTS //f : value of the cost function for the best parameter set //popt : best parameter set //yopt : fit function evaluated on the x dataset //gropt : gradient of the cost function at x //ci ; confidence interval @ 95% on each parameter in popt //pcovar ; covariance matrix of popt // CHECK x and y are col not row if isrow(x) then x=x.'; end if isrow(y) then y=y.'; end if (length(varargin) < 2) then // No constraints on parameter set were provided [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,p0); // [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); else // Constraints on parameter set were provided pinf=varargin(1); psup=varargin(2); [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,"b",pinf,psup,p0); end //normalized best fit evaluated on normalized x yopt=ErrorFitSine(popt, x, zeros(x)); //rescale best fit param g = dErrorFitSine(popt, x, y);//Jacobian matrix of the fit formula //estimate of the noise on the signal to fit sigma2=1/(length(x)-length(popt))*f; //covariance matrix of fitting parameters pcovar=inv(g'*g)*sigma2; //confidence interval for each parameter ci=1.96*sqrt(diag(pcovar)); ci=ci.'; endfunction // Let's use our unified and bullet-proof routine x=[-10:0.1:10]; //y=Sine(x,[1,2*%pi/3,4,1])+(2*rand(x)-1)*0.1; y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2; //y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2/10; p0=EstimateFitSine(x,y); [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0); str="$"+["x_0";"k";"A";"y_0"]+"="+string(popt.')+"\pm"+string(ci.')+"$"; str=["$\text{Model: }[y]=A\sin(k(x-x_0))+y_0$";str]; scf(); plot(x,y,'k.'); plot(x,SineModel(x,p0),'g'); plot(x,SineModel(x,popt),'r'); xlabel("$x$"); ylabel("$y$"); xtitle(str) legend(["Data";"Guess";"Fit"]) ////////////////////////////////////////////////////////////////////////////////////// Le Samedi, Avril 04, 2020 15:13 CEST, Heinz Nabielek a ?crit: > Scilab friends: the power of Scilab is amazing and I have used it recently for non-linear least-squares fitting, below example from Scilab help function for "datafit". On occasions, I have also used "leastsq". > > Question: how do I derive the 1sigma standard error in the three parameters p(1), p(2), and p(3)? And, if it is not too complicated, covariances? > > I know this is written in dozens of textbooks, but I am always getting lost. > Please provide a simple recipe written in Scilab. > Best greetings > Heinz > > > > // -- 04/04/2020 14:57:30 -- // > //generate the data > function y=FF(x, p) > y=p(1)*(x-p(2))+p(3)*x.*x > endfunction > X=[]; > Y=[]; > pg=[34;12;14] //parameter used to generate data > for x=0:.1:3 > Y=[Y,FF(x,pg)+100*(rand()-.5)]; > X=[X,x]; > end > Z=[Y;X]; > //The criterion function > function e=G(p, z), > y=z(1),x=z(2); > e=y-FF(x,p), > endfunction > //Solve the problem > p0=[3;5;10] > [p,err]=datafit(G,Z,p0); > scf(0);clf() > plot2d(X,FF(X,pg),5) //the curve without noise > plot2d(X,Y,-1) // the noisy data > plot2d(X,FF(X,p),12) //the solution > xgrid();legend("the curve without noise"," the noisy data", "THE FINAL SOLUTION.....",4); > title("solution set 39.868419 10.312053 11.482521","fontsize",4); From cfuttrup at gmail.com Mon Apr 6 08:43:10 2020 From: cfuttrup at gmail.com (Claus Futtrup) Date: Mon, 6 Apr 2020 08:43:10 +0200 Subject: [Scilab-users] ?==?utf-8?q? Error in parameters determined in non-linear least-squares fitting In-Reply-To: References: Message-ID: <28d94288-cf7d-793b-b74d-3725d579ff13@gmail.com> Hi Scilabers Good examples are worth a lot. Maybe this one could be part of the Scilab documentation? Best regards, Claus On 06.04.2020 08:17, Antoine Monmayrant wrote: > Hello Heinz, > > See below the small example I built and I refer to whenever I need to do some data fitting with confidence intervals for the parameters of the model. > It is far from perfect but it might help you untangle the Jacobian and covariance matrix thingy. > Just two words of caution: (1) I am clearly less versed in applied maths than St?phane or Samuel, so take this with a grain of salft; (2) I built this example ages ago, before Samuel improved datafit. > > Good luck > > Antoine > > ////////////////////////////////////////////////////////////////////////////////////// > // REFERENCE: > // > // Least Squares Estimation > // SARA A. VAN DE GEER > // Volume 2, pp. 1041?1045 > // in > // Encyclopedia of Statistics in Behavioral Science > // ISBN-13: 978-0-470-86080-9 > // ISBN-10: 0-470-86080-4 > // Editors Brian S. Everitt & David C. Howell > // John Wiley & Sons, Ltd, Chichester, 2005 > // > > //This is a short and definetly incomplete tutorial on data fitting in Scilab using leastsq. > // > // Basic assumption: this tutorial is for scientists that face this simple problem: > // they have an experimental dataset x_epx,y_exp and a certain model y=Model(x,p) to fit thie dataset. > // This tutorial will try to answer the folowing questions: > // 1) how do you do that (simply) > // 2) how do you do that (more reliably and more quickly) > // a) let's go faster with a Jacobian > // b) how good is your fit? How big is the "error bar" associated with each parameter of your Model? > // c) Can we bullet proof it? > > //1) How do you do curve fitting in Scilab > // > // We need a) a model function b) a dataset c) some more work > // 1)a) Let's start with the model function: a sinewave > // here is the formula: y=A*sin(k*(x-x0))+y0; > // here is the function prototypr [y]=SineModel(x,p) with p=[x0,k,A,y0]' > function [y]=SineModel(x,p) > //INPUTS: x 1D vector > // p parameter vector of size [4,1] containing > // x0 : sine origin > // k : sine spatial frequency ie k=2%pi/Xp with Xp the period > // A : sine amplitude > // y0 : sine offset > //OUTPUTS: y 1D vector of same size than x such that y=A*sin(k*(x-x0))+y0; > x0=p(1); > k=p(2); > A=p(3); > y0=p(4); > y=y0+A*sin((x-x0)*k); > endfunction > > // 1)b) Let's now have a fake dataset: a sine wave with some noise > // We reuse the Model function we have just created to make this fake dataset > > x_exp=[-10:0.1:10]'; > x0=1.55; > k=1*%pi/3; > A=4.3; > y0=1.1 > y_exp=SineModel(x_exp,[x0,k,A,y0])+(2*rand(x_exp)-1)*6/10; > > //let's check and see what it looks like: > scf(); > plot(x_exp,y_exp,'k.-'); > xlabel('Exparimental X'); > ylabel('Exparimental Y'); > xtitle('Our fake experimental dataset to fit'); > > // 1)c) we are not done yet, we need some more work > // First we need an error function that return for a given parameter set param the difference > // between the experimental dataset and the model one: > // Note that this function returns the difference at each point, not the square of the difference, > // nor the sum over each point of the square of the differences > function e = ErrorFitSine(param, x_exp, y_exp) > e = SineModel(x_exp,param)-y_exp; > endfunction > // Now we need a starting point that is not too far away from the solution > // Let's just fo it by hand for the moment we'll see later how to make it programmatically > // Just go and have a look at the previous plot and "guess", here is mine: > p0=[1,2*%pi/6,4,1]; > > //Ready to go: > [f,popt, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); > //popt contains the optimal parameter set that fits our dataset > // > scf(); > plot(x_exp,y_exp,'k.'); > plot(x_exp,SineModel(x_exp,popt),'r-'); > xlabel('Experimental X') > ylabel('Experimental Y and best fit'); > xtitle([... > "x0="+msprintf('%1.3f fit value: \t%1.3f',x0,popt(1));... > "k ="+msprintf('%1.3f fit value: \t%1.3f',k,popt(2));... > "A ="+msprintf('%1.3f fit value: \t%1.3f',A,popt(3));... > "y0="+msprintf('%1.3f fit value: \t%1.3f',y0,popt(4))... > ]); > > //Yep we are done popt is the optimal parameter set that fits our dataset x_exp,y_exp with our > // model SineModel > // How to assert the quality of our fit? We can use fopt and gropt for that. They should be both as small as possible. > // Ideally, the gradient should be zeros for each parameter, otherwise it means we have not found an optimum. > > //2) How to go beyond that simple example? > // Namely: > // a) how to go faster? > // b) how to estimate how good our fit is (aka get error bars on our parameters)? > // c) how to make thinks more reliable with less human guessing and more bulletproofing? > > > //2)a) and also 2)b) > // We need the same extra function in order to speed things up and to estimate > // how the "noise" on the experimental dataset translates in "noise" on each > // individual parameter p(1), ...p($): the Jacobian matrix of our fit model. > // Impressive name for a simple idea: providing leastsq with the partial > // derivative of the model formula with respect to each parameter p(1)..p($). > function g = ErrorJMatSine(p, x, y) > // > > // g(1,:) = d(SinModel(x,p))/dx0 = d(SinModel(x,p))/d(p(1)) > // g(2,:) = d(SinModel(x,p))/dk = d(SinModel(x,p))/d(p(2)) > // g(3,:) = d(SinModel(x,p))/dA = d(SinModel(x,p))/d(p(3)) > // g(4,:) = d(SinModel(x,p))/dy0 = d(SinModel(x,p))/d(p(4)) > > // y=A*sin(k*(x-x0))+y0; > x0=p(1); > k=p(2); > A=p(3); > y0=p(4); > g = [... > (-k)*SineModel(x,[x0-%pi/2/k,k,A,0]'),... > (x-x0).*SineModel(x,[x0-%pi/2/k,k,A,0]'),... > SineModel(x,[x0,k,1,0]'),... > ones(x) ... > ]; > endfunction > > > //Ready to go again, and faster this time: > [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); > > disp("This should be ~ [0,0,0] when both fits give exactly the same results") > disp(string((popt-popt_fast)./(popt+popt_fast))) > > //Now we check that we are faster: > // we do it several times to average over timing variations caused by > // other processes running on our computer > speedup=zeros(1,10) > for i=1:100 > tic(); > [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); > t1=toc(); > tic(); > [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); > t2=toc(); > speedup(i)=t1/t2; > end > > scf(); > plot(speedup,'k.'); > plot(mean(speedup)*ones(speedup),'r'); > xlabel("Fit iteration"); > ylabel("SpeedUp factor when using Jacobian Matrix"); > xtitle("Here we have a "+msprintf("~%1.2f",mean(speedup))+... > " speed improvement using the Jacobian Matrix"); > > //2)b) How can we estimate "error bars" for each individual parameters? > // We are going to estimate how the "noise" on our dataset turns into > // noise on each parameter by estimating the confidence interval at 95% > > g = ErrorJMatSine(popt_fast, x_exp, y_exp);//Jacobian matrix of the fit formula > //estimate of the initial noise on the dataset to fit > sigma2=1/(length(x_exp)-length(popt_fast))*f; > > //covariance matrix of fitting parameters > pcovar=inv(g'*g)*sigma2; > //confidence interval for each parameter > ci=(1.96*sqrt(diag(pcovar)))'; > > //Let's present the results of the confidence interval calculation > str=msprintf("%4.3f\n", popt_fast')+' +/- '+msprintf("%4.3f\n", ci'); > str=[["x0 = ";"k = ";"A = ";"y0 = "]+str]; > str=["Fit results:";"y=A*sin(k*(x-x0))+y0";"Param +/- conf. interval @ 95%";str] > > scf(); > plot(x_exp,y_exp,'k.'); > plot(x_exp,SineModel(x_exp,popt_fast),'r-'); > xlabel('Experimental X') > ylabel('Experimental Y and best fit'); > xtitle('Fit with confidence intervals at 95%'); > xstringb(-6,-3,str,12,6,'fill'); > e=gce(); > e.box="on"; > e.fill_mode="on"; > e.background=color("light gray"); > > //Now we have a fast fit function that can give some estimation on > // how seriously we can believe the fitted parameters. > // You can see that the precision with which we retrieve each parameter varies > // k0 is more precisely determined than y0 (15x more precisely!) > //You can play with the amount of noise to see how it affects the retrieved > // parameters and confidence intervals > > > > //2)b) How can we bullet proof our fitting script by putting all this stuff > // together is several functions that checks the arguments and modify > // them if needed to avoid difficult to understand complaints from > // leastsq? > > // test of a sinus fitting routine > > //// y=A*sin(k*(x-x0))+y0; > //// function [y]=Sine(x,x0,k,A,y0) > //// function [y]=Sine(x,p) with p=[x0,k,A,y0]' > //function [y]=Sine(x,varargin) > //// pause > // select length(varargin) > // case 1 then > // //we use form [y]=Sine(x,p) where p=[x0,dx,A,y0]' > // p=varargin(1); > // case 4 then > // //we use form [y]=Sine(x,x0,k,A,y0) > // p=[varargin(1);varargin(2);varargin(3);varargin(4)]; > // else > // //call is not correct, we give up > // y=[];return > // end > // x0=p(1); > // k=p(2); > // A=p(3); > // y0=p(4); > // y=y0+A*sin((x-x0)*k); > //endfunction > // > function [p0,pinf,psup]=EstimateFitSine(x,y) > // y=A*sin(k*(x-x0))+y0; > y0=mean(y); > A=(max(y)-min(y))/2; > // pause > sy=fftshift(fft(y-mean(y))); > //sy=fft(y-mean(y)); > msy=max(abs(sy));rg=find(abs(sy)==msy); > delta=(rg(2)-rg(1))/length(y); > k=delta*%pi/(mean(diff(x))); > x0=mean(abs(atan(imag(sy(rg)),real(sy(rg)))/k))+%pi/2/k; > p0=[x0,k,A,y0]; > pinf=[min(x),0 ,-%inf ,-%inf]; > psup=[max(x),%inf ,%inf ,%inf]; > endfunction > > > function e = ErrorFitSine(param, xi, yi) > e = SineModel(xi,param)-yi; > endfunction > > function g = dErrorFitSine(param, xi, yi) > // y=A*sin(k*(x-x0))+y0; > x0=param(1); > k=param(2); > A=param(3); > y0=param(4); > // pause > g = [... > (-k)*SineModel(xi,[x0-%pi/2/k,k,A,0]),... > (xi-x0).*SineModel(xi,[x0-%pi/2/k,k,A,0]),... > SineModel(xi,[x0,k,1,0]),... > ones(xi) ... > ]; > endfunction > > > > function [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0,varargin) > // FIT Experimental dataset y(x) with a sine model > // [y]=A*sin(k*(x-x0))+y0; > // > //INPUTS: > //x : experiemental x dataset > //y : experimental y dataset > //p0 : starting parameter set [x0,k,A,y0] > //varargin : > // pinf inferior limit for popt > // psup superior limit for popt > //OUTPUTS > //f : value of the cost function for the best parameter set > //popt : best parameter set > //yopt : fit function evaluated on the x dataset > //gropt : gradient of the cost function at x > //ci ; confidence interval @ 95% on each parameter in popt > //pcovar ; covariance matrix of popt > > // CHECK x and y are col not row > if isrow(x) then > x=x.'; > end > if isrow(y) then > y=y.'; > end > > if (length(varargin) < 2) then > // No constraints on parameter set were provided > [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,p0); > // [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); > else > // Constraints on parameter set were provided > pinf=varargin(1); > psup=varargin(2); > [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,"b",pinf,psup,p0); > end > //normalized best fit evaluated on normalized x > yopt=ErrorFitSine(popt, x, zeros(x)); > //rescale best fit param > > g = dErrorFitSine(popt, x, y);//Jacobian matrix of the fit formula > //estimate of the noise on the signal to fit > sigma2=1/(length(x)-length(popt))*f; > > //covariance matrix of fitting parameters > pcovar=inv(g'*g)*sigma2; > //confidence interval for each parameter > ci=1.96*sqrt(diag(pcovar)); > ci=ci.'; > endfunction > > > // Let's use our unified and bullet-proof routine > > x=[-10:0.1:10]; > //y=Sine(x,[1,2*%pi/3,4,1])+(2*rand(x)-1)*0.1; > y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2; > //y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2/10; > > p0=EstimateFitSine(x,y); > [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0); > > > str="$"+["x_0";"k";"A";"y_0"]+"="+string(popt.')+"\pm"+string(ci.')+"$"; > str=["$\text{Model: }[y]=A\sin(k(x-x_0))+y_0$";str]; > > scf(); > plot(x,y,'k.'); > plot(x,SineModel(x,p0),'g'); > plot(x,SineModel(x,popt),'r'); > xlabel("$x$"); > ylabel("$y$"); > xtitle(str) > legend(["Data";"Guess";"Fit"]) > > ////////////////////////////////////////////////////////////////////////////////////// > > Le Samedi, Avril 04, 2020 15:13 CEST, Heinz Nabielek a ?crit: > >> Scilab friends: the power of Scilab is amazing and I have used it recently for non-linear least-squares fitting, below example from Scilab help function for "datafit". On occasions, I have also used "leastsq". >> >> Question: how do I derive the 1sigma standard error in the three parameters p(1), p(2), and p(3)? And, if it is not too complicated, covariances? >> >> I know this is written in dozens of textbooks, but I am always getting lost. >> Please provide a simple recipe written in Scilab. >> Best greetings >> Heinz >> >> >> >> // -- 04/04/2020 14:57:30 -- // >> //generate the data >> function y=FF(x, p) >> y=p(1)*(x-p(2))+p(3)*x.*x >> endfunction >> X=[]; >> Y=[]; >> pg=[34;12;14] //parameter used to generate data >> for x=0:.1:3 >> Y=[Y,FF(x,pg)+100*(rand()-.5)]; >> X=[X,x]; >> end >> Z=[Y;X]; >> //The criterion function >> function e=G(p, z), >> y=z(1),x=z(2); >> e=y-FF(x,p), >> endfunction >> //Solve the problem >> p0=[3;5;10] >> [p,err]=datafit(G,Z,p0); >> scf(0);clf() >> plot2d(X,FF(X,pg),5) //the curve without noise >> plot2d(X,Y,-1) // the noisy data >> plot2d(X,FF(X,p),12) //the solution >> xgrid();legend("the curve without noise"," the noisy data", "THE FINAL SOLUTION.....",4); >> title("solution set 39.868419 10.312053 11.482521","fontsize",4); > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From amonmayr at laas.fr Mon Apr 6 09:40:19 2020 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Mon, 06 Apr 2020 09:40:19 +0200 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ID89PT91dGYtOD9xPyA/PSBF?= =?utf-8?q?rror_in_parameters_determined_in_non-linear_least-squares_fitti?= =?utf-8?q?n?= In-Reply-To: <28d94288-cf7d-793b-b74d-3725d579ff13@gmail.com> Message-ID: <5079-5e8add00-11-15f56b20@211706307> Hi all, I would appreciate comments/corrections&improvements from you guys as I am far from a specialist in this field! If some of you find this example useful, I can try to work a bit to improve it and push it as an atom module. In fact, I have a bunch of other fit functions (like gaussian, diode-like curve, ...) that follow the same approach than the sinewave example and I've long wanted to bundle them in a module where one can add a new fit function by providing the model, error, jacobian and estimate functions like in my example... Antoine Le Lundi, Avril 06, 2020 08:43 CEST, Claus Futtrup a ?crit: > Hi Scilabers > > Good examples are worth a lot. Maybe this one could be part of the > Scilab documentation? > > Best regards, > Claus > > On 06.04.2020 08:17, Antoine Monmayrant wrote: > > Hello Heinz, > > > > See below the small example I built and I refer to whenever I need to do some data fitting with confidence intervals for the parameters of the model. > > It is far from perfect but it might help you untangle the Jacobian and covariance matrix thingy. > > Just two words of caution: (1) I am clearly less versed in applied maths than St?phane or Samuel, so take this with a grain of salft; (2) I built this example ages ago, before Samuel improved datafit. > > > > Good luck > > > > Antoine > > > > ////////////////////////////////////////////////////////////////////////////////////// > > // REFERENCE: > > // > > // Least Squares Estimation > > // SARA A. VAN DE GEER > > // Volume 2, pp. 1041?1045 > > // in > > // Encyclopedia of Statistics in Behavioral Science > > // ISBN-13: 978-0-470-86080-9 > > // ISBN-10: 0-470-86080-4 > > // Editors Brian S. Everitt & David C. Howell > > // John Wiley & Sons, Ltd, Chichester, 2005 > > // > > > > //This is a short and definetly incomplete tutorial on data fitting in Scilab using leastsq. > > // > > // Basic assumption: this tutorial is for scientists that face this simple problem: > > // they have an experimental dataset x_epx,y_exp and a certain model y=Model(x,p) to fit thie dataset. > > // This tutorial will try to answer the folowing questions: > > // 1) how do you do that (simply) > > // 2) how do you do that (more reliably and more quickly) > > // a) let's go faster with a Jacobian > > // b) how good is your fit? How big is the "error bar" associated with each parameter of your Model? > > // c) Can we bullet proof it? > > > > //1) How do you do curve fitting in Scilab > > // > > // We need a) a model function b) a dataset c) some more work > > // 1)a) Let's start with the model function: a sinewave > > // here is the formula: y=A*sin(k*(x-x0))+y0; > > // here is the function prototypr [y]=SineModel(x,p) with p=[x0,k,A,y0]' > > function [y]=SineModel(x,p) > > //INPUTS: x 1D vector > > // p parameter vector of size [4,1] containing > > // x0 : sine origin > > // k : sine spatial frequency ie k=2%pi/Xp with Xp the period > > // A : sine amplitude > > // y0 : sine offset > > //OUTPUTS: y 1D vector of same size than x such that y=A*sin(k*(x-x0))+y0; > > x0=p(1); > > k=p(2); > > A=p(3); > > y0=p(4); > > y=y0+A*sin((x-x0)*k); > > endfunction > > > > // 1)b) Let's now have a fake dataset: a sine wave with some noise > > // We reuse the Model function we have just created to make this fake dataset > > > > x_exp=[-10:0.1:10]'; > > x0=1.55; > > k=1*%pi/3; > > A=4.3; > > y0=1.1 > > y_exp=SineModel(x_exp,[x0,k,A,y0])+(2*rand(x_exp)-1)*6/10; > > > > //let's check and see what it looks like: > > scf(); > > plot(x_exp,y_exp,'k.-'); > > xlabel('Exparimental X'); > > ylabel('Exparimental Y'); > > xtitle('Our fake experimental dataset to fit'); > > > > // 1)c) we are not done yet, we need some more work > > // First we need an error function that return for a given parameter set param the difference > > // between the experimental dataset and the model one: > > // Note that this function returns the difference at each point, not the square of the difference, > > // nor the sum over each point of the square of the differences > > function e = ErrorFitSine(param, x_exp, y_exp) > > e = SineModel(x_exp,param)-y_exp; > > endfunction > > // Now we need a starting point that is not too far away from the solution > > // Let's just fo it by hand for the moment we'll see later how to make it programmatically > > // Just go and have a look at the previous plot and "guess", here is mine: > > p0=[1,2*%pi/6,4,1]; > > > > //Ready to go: > > [f,popt, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); > > //popt contains the optimal parameter set that fits our dataset > > // > > scf(); > > plot(x_exp,y_exp,'k.'); > > plot(x_exp,SineModel(x_exp,popt),'r-'); > > xlabel('Experimental X') > > ylabel('Experimental Y and best fit'); > > xtitle([... > > "x0="+msprintf('%1.3f fit value: \t%1.3f',x0,popt(1));... > > "k ="+msprintf('%1.3f fit value: \t%1.3f',k,popt(2));... > > "A ="+msprintf('%1.3f fit value: \t%1.3f',A,popt(3));... > > "y0="+msprintf('%1.3f fit value: \t%1.3f',y0,popt(4))... > > ]); > > > > //Yep we are done popt is the optimal parameter set that fits our dataset x_exp,y_exp with our > > // model SineModel > > // How to assert the quality of our fit? We can use fopt and gropt for that. They should be both as small as possible. > > // Ideally, the gradient should be zeros for each parameter, otherwise it means we have not found an optimum. > > > > //2) How to go beyond that simple example? > > // Namely: > > // a) how to go faster? > > // b) how to estimate how good our fit is (aka get error bars on our parameters)? > > // c) how to make thinks more reliable with less human guessing and more bulletproofing? > > > > > > //2)a) and also 2)b) > > // We need the same extra function in order to speed things up and to estimate > > // how the "noise" on the experimental dataset translates in "noise" on each > > // individual parameter p(1), ...p($): the Jacobian matrix of our fit model. > > // Impressive name for a simple idea: providing leastsq with the partial > > // derivative of the model formula with respect to each parameter p(1)..p($). > > function g = ErrorJMatSine(p, x, y) > > // > > > > // g(1,:) = d(SinModel(x,p))/dx0 = d(SinModel(x,p))/d(p(1)) > > // g(2,:) = d(SinModel(x,p))/dk = d(SinModel(x,p))/d(p(2)) > > // g(3,:) = d(SinModel(x,p))/dA = d(SinModel(x,p))/d(p(3)) > > // g(4,:) = d(SinModel(x,p))/dy0 = d(SinModel(x,p))/d(p(4)) > > > > // y=A*sin(k*(x-x0))+y0; > > x0=p(1); > > k=p(2); > > A=p(3); > > y0=p(4); > > g = [... > > (-k)*SineModel(x,[x0-%pi/2/k,k,A,0]'),... > > (x-x0).*SineModel(x,[x0-%pi/2/k,k,A,0]'),... > > SineModel(x,[x0,k,1,0]'),... > > ones(x) ... > > ]; > > endfunction > > > > > > //Ready to go again, and faster this time: > > [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); > > > > disp("This should be ~ [0,0,0] when both fits give exactly the same results") > > disp(string((popt-popt_fast)./(popt+popt_fast))) > > > > //Now we check that we are faster: > > // we do it several times to average over timing variations caused by > > // other processes running on our computer > > speedup=zeros(1,10) > > for i=1:100 > > tic(); > > [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); > > t1=toc(); > > tic(); > > [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); > > t2=toc(); > > speedup(i)=t1/t2; > > end > > > > scf(); > > plot(speedup,'k.'); > > plot(mean(speedup)*ones(speedup),'r'); > > xlabel("Fit iteration"); > > ylabel("SpeedUp factor when using Jacobian Matrix"); > > xtitle("Here we have a "+msprintf("~%1.2f",mean(speedup))+... > > " speed improvement using the Jacobian Matrix"); > > > > //2)b) How can we estimate "error bars" for each individual parameters? > > // We are going to estimate how the "noise" on our dataset turns into > > // noise on each parameter by estimating the confidence interval at 95% > > > > g = ErrorJMatSine(popt_fast, x_exp, y_exp);//Jacobian matrix of the fit formula > > //estimate of the initial noise on the dataset to fit > > sigma2=1/(length(x_exp)-length(popt_fast))*f; > > > > //covariance matrix of fitting parameters > > pcovar=inv(g'*g)*sigma2; > > //confidence interval for each parameter > > ci=(1.96*sqrt(diag(pcovar)))'; > > > > //Let's present the results of the confidence interval calculation > > str=msprintf("%4.3f\n", popt_fast')+' +/- '+msprintf("%4.3f\n", ci'); > > str=[["x0 = ";"k = ";"A = ";"y0 = "]+str]; > > str=["Fit results:";"y=A*sin(k*(x-x0))+y0";"Param +/- conf. interval @ 95%";str] > > > > scf(); > > plot(x_exp,y_exp,'k.'); > > plot(x_exp,SineModel(x_exp,popt_fast),'r-'); > > xlabel('Experimental X') > > ylabel('Experimental Y and best fit'); > > xtitle('Fit with confidence intervals at 95%'); > > xstringb(-6,-3,str,12,6,'fill'); > > e=gce(); > > e.box="on"; > > e.fill_mode="on"; > > e.background=color("light gray"); > > > > //Now we have a fast fit function that can give some estimation on > > // how seriously we can believe the fitted parameters. > > // You can see that the precision with which we retrieve each parameter varies > > // k0 is more precisely determined than y0 (15x more precisely!) > > //You can play with the amount of noise to see how it affects the retrieved > > // parameters and confidence intervals > > > > > > > > //2)b) How can we bullet proof our fitting script by putting all this stuff > > // together is several functions that checks the arguments and modify > > // them if needed to avoid difficult to understand complaints from > > // leastsq? > > > > // test of a sinus fitting routine > > > > //// y=A*sin(k*(x-x0))+y0; > > //// function [y]=Sine(x,x0,k,A,y0) > > //// function [y]=Sine(x,p) with p=[x0,k,A,y0]' > > //function [y]=Sine(x,varargin) > > //// pause > > // select length(varargin) > > // case 1 then > > // //we use form [y]=Sine(x,p) where p=[x0,dx,A,y0]' > > // p=varargin(1); > > // case 4 then > > // //we use form [y]=Sine(x,x0,k,A,y0) > > // p=[varargin(1);varargin(2);varargin(3);varargin(4)]; > > // else > > // //call is not correct, we give up > > // y=[];return > > // end > > // x0=p(1); > > // k=p(2); > > // A=p(3); > > // y0=p(4); > > // y=y0+A*sin((x-x0)*k); > > //endfunction > > // > > function [p0,pinf,psup]=EstimateFitSine(x,y) > > // y=A*sin(k*(x-x0))+y0; > > y0=mean(y); > > A=(max(y)-min(y))/2; > > // pause > > sy=fftshift(fft(y-mean(y))); > > //sy=fft(y-mean(y)); > > msy=max(abs(sy));rg=find(abs(sy)==msy); > > delta=(rg(2)-rg(1))/length(y); > > k=delta*%pi/(mean(diff(x))); > > x0=mean(abs(atan(imag(sy(rg)),real(sy(rg)))/k))+%pi/2/k; > > p0=[x0,k,A,y0]; > > pinf=[min(x),0 ,-%inf ,-%inf]; > > psup=[max(x),%inf ,%inf ,%inf]; > > endfunction > > > > > > function e = ErrorFitSine(param, xi, yi) > > e = SineModel(xi,param)-yi; > > endfunction > > > > function g = dErrorFitSine(param, xi, yi) > > // y=A*sin(k*(x-x0))+y0; > > x0=param(1); > > k=param(2); > > A=param(3); > > y0=param(4); > > // pause > > g = [... > > (-k)*SineModel(xi,[x0-%pi/2/k,k,A,0]),... > > (xi-x0).*SineModel(xi,[x0-%pi/2/k,k,A,0]),... > > SineModel(xi,[x0,k,1,0]),... > > ones(xi) ... > > ]; > > endfunction > > > > > > > > function [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0,varargin) > > // FIT Experimental dataset y(x) with a sine model > > // [y]=A*sin(k*(x-x0))+y0; > > // > > //INPUTS: > > //x : experiemental x dataset > > //y : experimental y dataset > > //p0 : starting parameter set [x0,k,A,y0] > > //varargin : > > // pinf inferior limit for popt > > // psup superior limit for popt > > //OUTPUTS > > //f : value of the cost function for the best parameter set > > //popt : best parameter set > > //yopt : fit function evaluated on the x dataset > > //gropt : gradient of the cost function at x > > //ci ; confidence interval @ 95% on each parameter in popt > > //pcovar ; covariance matrix of popt > > > > // CHECK x and y are col not row > > if isrow(x) then > > x=x.'; > > end > > if isrow(y) then > > y=y.'; > > end > > > > if (length(varargin) < 2) then > > // No constraints on parameter set were provided > > [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,p0); > > // [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); > > else > > // Constraints on parameter set were provided > > pinf=varargin(1); > > psup=varargin(2); > > [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,"b",pinf,psup,p0); > > end > > //normalized best fit evaluated on normalized x > > yopt=ErrorFitSine(popt, x, zeros(x)); > > //rescale best fit param > > > > g = dErrorFitSine(popt, x, y);//Jacobian matrix of the fit formula > > //estimate of the noise on the signal to fit > > sigma2=1/(length(x)-length(popt))*f; > > > > //covariance matrix of fitting parameters > > pcovar=inv(g'*g)*sigma2; > > //confidence interval for each parameter > > ci=1.96*sqrt(diag(pcovar)); > > ci=ci.'; > > endfunction > > > > > > // Let's use our unified and bullet-proof routine > > > > x=[-10:0.1:10]; > > //y=Sine(x,[1,2*%pi/3,4,1])+(2*rand(x)-1)*0.1; > > y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2; > > //y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2/10; > > > > p0=EstimateFitSine(x,y); > > [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0); > > > > > > str="$"+["x_0";"k";"A";"y_0"]+"="+string(popt.')+"\pm"+string(ci.')+"$"; > > str=["$\text{Model: }[y]=A\sin(k(x-x_0))+y_0$";str]; > > > > scf(); > > plot(x,y,'k.'); > > plot(x,SineModel(x,p0),'g'); > > plot(x,SineModel(x,popt),'r'); > > xlabel("$x$"); > > ylabel("$y$"); > > xtitle(str) > > legend(["Data";"Guess";"Fit"]) > > > > ////////////////////////////////////////////////////////////////////////////////////// > > > > Le Samedi, Avril 04, 2020 15:13 CEST, Heinz Nabielek a ?crit: > > > >> Scilab friends: the power of Scilab is amazing and I have used it recently for non-linear least-squares fitting, below example from Scilab help function for "datafit". On occasions, I have also used "leastsq". > >> > >> Question: how do I derive the 1sigma standard error in the three parameters p(1), p(2), and p(3)? And, if it is not too complicated, covariances? > >> > >> I know this is written in dozens of textbooks, but I am always getting lost. > >> Please provide a simple recipe written in Scilab. > >> Best greetings > >> Heinz > >> > >> > >> > >> // -- 04/04/2020 14:57:30 -- // > >> //generate the data > >> function y=FF(x, p) > >> y=p(1)*(x-p(2))+p(3)*x.*x > >> endfunction > >> X=[]; > >> Y=[]; > >> pg=[34;12;14] //parameter used to generate data > >> for x=0:.1:3 > >> Y=[Y,FF(x,pg)+100*(rand()-.5)]; > >> X=[X,x]; > >> end > >> Z=[Y;X]; > >> //The criterion function > >> function e=G(p, z), > >> y=z(1),x=z(2); > >> e=y-FF(x,p), > >> endfunction > >> //Solve the problem > >> p0=[3;5;10] > >> [p,err]=datafit(G,Z,p0); > >> scf(0);clf() > >> plot2d(X,FF(X,pg),5) //the curve without noise > >> plot2d(X,Y,-1) // the noisy data > >> plot2d(X,FF(X,p),12) //the solution > >> xgrid();legend("the curve without noise"," the noisy data", "THE FINAL SOLUTION.....",4); > >> title("solution set 39.868419 10.312053 11.482521","fontsize",4); > > _______________________________________________ > > users mailing list > > users at lists.scilab.org > > http://lists.scilab.org/mailman/listinfo/users > > > > -- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From bonnin.cedric at gmail.com Mon Apr 6 11:41:34 2020 From: bonnin.cedric at gmail.com (Cruz) Date: Mon, 6 Apr 2020 02:41:34 -0700 (MST) Subject: [Scilab-users] ODE : Second order coupled differential equations Message-ID: <1586166094307-0.post@n3.nabble.com> Hello everybody, I have a system of 2 differential equations (Eq.1 and Eq.2) coupled of order 2 as shown in the attached image. Normally, I can easily find the solution by transforming this system onto a system of order 1 by changing variables. The variables theta and r are functions of time. I use the ODE solver integrated in Scilab. Here is my code : ------------------------------------------------------------------ t0 = 0; // initial time (s) tmax = 30; // solving max time (s) tinc = 0.005; // time increment (s) t = t0:tinc:tmax; // Differential equations system function du = equadiff(t,u) // d for derivative with respect to time t // u(1) = theta // u(2) = d(theta)/dt // u(3) = r // u(4) = d(r)/dt // du(1) = d(theta)/dt // du(2) = d?(theta)dt? // du(3) = d(r)/dt // du(4) = d?(r)/dt? F1=1300; F2=1000; l=13; k=68000; menv = 112.14; m0 = 56.07; g=9.81; m = (menv - m0) * (1-abs(cos(u(1)))) + m0; du(1) = u(2); du(2) = (F2*sin(u(1)) + (F1-m*g).*cos(u(1)) - 2*m.*u(4).*u(2)) ./ (m.*u(3)); du(3) = u(4); du(4) = ((F1-m*g).*sin(u(1)) - F2*cos(u(1)) - k*(u(3)-l) + m.*u(3).*u(2).*u(2)) ./ m; endfunction // Integration u0 = [0,0,13,0]; [u] = ode(u0,t0,t,equadiff); ------------------------------------------------------------------ The problem is that the output of the solver, [u], should be a matrix of 4 lines and 6001 columns: 4 lines: u (1) = theta u (2) = d (theta) / dt u (3) = r u (4) = d (r) / dt 6001 columns: tmax / tinc = 6000 time step + the initial instant t0 = 6001 At the end of the calculation I get size (u) ans = 1. 24004. instead of 4. 6001. It seems to me to proceed in the standard way for this type of problem. Someone have any idea why it doesn't work? Thanks in advance to all ! -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From stephane.mottelet at utc.fr Mon Apr 6 11:47:19 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Mon, 6 Apr 2020 11:47:19 +0200 Subject: [Scilab-users] ODE : Second order coupled differential equations In-Reply-To: <1586166094307-0.post@n3.nabble.com> References: <1586166094307-0.post@n3.nabble.com> Message-ID: Hello, Try to transpose u0. S. Le 06/04/2020 ? 11:41, Cruz a ?crit?: > Hello everybody, > > I have a system of 2 differential equations (Eq.1 and Eq.2) coupled of order > 2 as shown in the attached image. Normally, I can easily find the solution > by transforming this system onto a system of order 1 by changing variables. > > > > The variables theta and r are functions of time. I use the ODE solver > integrated in Scilab. > > Here is my code : > > ------------------------------------------------------------------ > > t0 = 0; // initial time (s) > tmax = 30; // solving max time (s) > tinc = 0.005; // time increment (s) > > t = t0:tinc:tmax; > > // Differential equations system > > function du = equadiff(t,u) > > // d for derivative with respect to time t > // u(1) = theta > // u(2) = d(theta)/dt > // u(3) = r > // u(4) = d(r)/dt > // du(1) = d(theta)/dt > // du(2) = d?(theta)dt? > // du(3) = d(r)/dt > // du(4) = d?(r)/dt? > > F1=1300; > F2=1000; > l=13; > k=68000; > menv = 112.14; > m0 = 56.07; > g=9.81; > > m = (menv - m0) * (1-abs(cos(u(1)))) + m0; > > du(1) = u(2); > du(2) = (F2*sin(u(1)) + (F1-m*g).*cos(u(1)) - 2*m.*u(4).*u(2)) ./ > (m.*u(3)); > du(3) = u(4); > du(4) = ((F1-m*g).*sin(u(1)) - F2*cos(u(1)) - k*(u(3)-l) + > m.*u(3).*u(2).*u(2)) ./ m; > > endfunction > > // Integration > > u0 = [0,0,13,0]; > [u] = ode(u0,t0,t,equadiff); > > ------------------------------------------------------------------ > > The problem is that the output of the solver, [u], should be a matrix of 4 > lines and 6001 columns: > > 4 lines: > > u (1) = theta > u (2) = d (theta) / dt > u (3) = r > u (4) = d (r) / dt > > 6001 columns: > > tmax / tinc = 6000 time step + the initial instant t0 = 6001 > > At the end of the calculation I get > > size (u) > > ans = > > 1. 24004. > > instead of > > 4. 6001. > > It seems to me to proceed in the standard way for this type of problem. > Someone have any idea why it doesn't work? > > Thanks in advance to all ! > > > > > > > > > > > -- > Sent from: https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html > _______________________________________________ > 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 From bonnin.cedric at gmail.com Mon Apr 6 12:09:27 2020 From: bonnin.cedric at gmail.com (Cruz) Date: Mon, 6 Apr 2020 03:09:27 -0700 (MST) Subject: [Scilab-users] ODE : Second order coupled differential equations In-Reply-To: References: <1586166094307-0.post@n3.nabble.com> Message-ID: <1586167767287-0.post@n3.nabble.com> Hello St?phane, thank you. I introduced u0 = [0,0,13,0]'; but it had no effect. C?dric -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From bonnin.cedric at gmail.com Mon Apr 6 12:26:10 2020 From: bonnin.cedric at gmail.com (Cruz) Date: Mon, 6 Apr 2020 03:26:10 -0700 (MST) Subject: [Scilab-users] ODE : Second order coupled differential equations In-Reply-To: <1586167767287-0.post@n3.nabble.com> References: <1586166094307-0.post@n3.nabble.com> <1586167767287-0.post@n3.nabble.com> Message-ID: <1586168770742-0.post@n3.nabble.com> I apologize, it worked ! Thank you St?phane ! -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From danielstringarita at gmail.com Tue Apr 7 00:13:13 2020 From: danielstringarita at gmail.com (Daniel Stringari) Date: Mon, 6 Apr 2020 19:13:13 -0300 Subject: [Scilab-users] Efficiency map Message-ID: Dear friends, I'm still a layman at SCILAB, but I'm using SCILAB this week to be able to plot an efficiency map through a routine I created on it. Basically the efficiency map is summarized in* annex 1_0 and annex 1_1*(I took it from the internet to exemplify the problem), where through a TORQUE X SPEED curve I have efficiency lines. In *annex 2*, I have an example of how my curve looks so far. Based on the example, I have two problems: 1) I tried to use the SPLIN function to interpolate the points, but it doesn't work considering that it works only with strictly increasing vectors. Any suggestions for me to smooth the curve? 2) When trying to add colors, I realized that most plotting functions do not work with values that are not real, which is my case ... All values with decimal places. Any suggestions for solving this other problem? Friends, I appreciate any form of help... attachments: https://drive.google.com/open?id=1DZORDJfpoezDhzYYyn4oold1O1V1Yz0Z -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmiyara at fceia.unr.edu.ar Tue Apr 7 02:27:46 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Mon, 6 Apr 2020 21:27:46 -0300 Subject: [Scilab-users] question non datafit In-Reply-To: <528dc3ab-5c8d-cab1-a47d-cbaa73af95d8@free.fr> References: <528dc3ab-5c8d-cab1-a47d-cbaa73af95d8@free.fr> Message-ID: <0ead17fa-9a44-69d4-cbd9-84efdd63a9e2@fceia.unr.edu.ar> Samuel: Oh, this is embarrasing... I did a web search on non-linear fit and somehow the top results always point at an outdated version (5.5.2) of Scilab's documentation. I wonder why Thanks, the new documentation is much better! Regerds, Federico Miyara On 04/04/2020 06:58, Samuel Gougeon wrote: > Le 04/04/2020 ? 09:26, Federico Miyara a ?crit?: >> >> Dear All, >> >> I'm trying to understand the function datafit. >> >> The documentation says: >> >> datafit is used for fitting data to a model. For a given function >> G(p,z), this function finds the best vector of parameters p for >> approximating G(p,z_i)=0 for a set of measurement vectors z_i. >> Vector p is found by minimizing >> G(p,z_1)'WG(p,z_1)+G(p,z_2)'WG(p,z_2)+...+G(p,z_n)'WG(p,z_n) >> >> >> I don't quite understand what is G(p,z_1)'WG(p,z_1). Are some product >> signs * missing? Shouldn't it be G(p,z_1)'*W*G(p,z_1)? Are these >> signs implied as in regular algebra notation? > > > Hello Federico, > Please see the documentation of the /latest/ scilab release: > https://help.scilab.org/docs/6.1.0/en_US/datafit.html > Regards > > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From Clement.David at esi-group.com Tue Apr 7 10:54:57 2020 From: Clement.David at esi-group.com (=?utf-8?B?Q2zDqW1lbnQgRGF2aWQ=?=) Date: Tue, 7 Apr 2020 08:54:57 +0000 Subject: [Scilab-users] question non datafit In-Reply-To: <0ead17fa-9a44-69d4-cbd9-84efdd63a9e2@fceia.unr.edu.ar> References: <528dc3ab-5c8d-cab1-a47d-cbaa73af95d8@free.fr> <0ead17fa-9a44-69d4-cbd9-84efdd63a9e2@fceia.unr.edu.ar> Message-ID: Hello Federico, hello all, Thanks for pointing this, it looks like there is some missing URL redirect somewhere. google "help scilab datafit" on a private navigation tab redirect to the 5.3.3 help page whereas https://help.scilab.org/datafit looks OK. I will try to update the index to improve that, a related bug is #12746. See https://bugzilla.scilab.org/show_bug.cgi?id=12746 for more information and discussion on that topic, do not hesitate to contribute if you have some SEO knowledge. Thanks, -- Cl?ment > -----Original Message----- > From: users On Behalf Of Federico > Miyara > Sent: Tuesday, April 7, 2020 2:28 AM > To: users at lists.scilab.org > Subject: Re: [Scilab-users] question non datafit > > > Samuel: > > Oh, this is embarrasing... I did a web search on non-linear fit and > somehow the top results always point at an outdated version (5.5.2) of > Scilab's documentation. I wonder why > > Thanks, the new documentation is much better! > > Regerds, > > Federico Miyara > > > > > On 04/04/2020 06:58, Samuel Gougeon wrote: > > > Le 04/04/2020 ? 09:26, Federico Miyara a ?crit : > > > > Dear All, > > I'm trying to understand the function datafit. > > The documentation says: > > > > datafit is used for fitting data to a model. For a given function > G(p,z), this function finds the best vector of parameters p for > approximating G(p,z_i)=0 for a set of measurement vectors z_i. Vector > p is found by minimizing > G(p,z_1)'WG(p,z_1)+G(p,z_2)'WG(p,z_2)+...+G(p,z_n)'WG(p,z_n) > > > > I don't quite understand what is G(p,z_1)'WG(p,z_1). Are some > product signs * missing? Shouldn't it be G(p,z_1)'*W*G(p,z_1)? Are > these signs implied as in regular algebra notation? > > > > > > Hello Federico, > Please see the documentation of the latest scilab release: > https://help.scilab.org/docs/6.1.0/en_US/datafit.html > Regards > > > > > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From cfuttrup at gmail.com Tue Apr 7 15:06:06 2020 From: cfuttrup at gmail.com (Claus Futtrup) Date: Tue, 7 Apr 2020 15:06:06 +0200 Subject: [Scilab-users] question non datafit In-Reply-To: References: <528dc3ab-5c8d-cab1-a47d-cbaa73af95d8@free.fr> <0ead17fa-9a44-69d4-cbd9-84efdd63a9e2@fceia.unr.edu.ar> Message-ID: <414c4bfd-cd19-ceb6-e530-8967bd26e605@gmail.com> Hi guys Since I'm interested in the topic, I decided to look up the link (https://help.scilab.org/datafit) on my phone. I was unable to see the majority of the graphs on the right and I was unable to zoom out. I am able to 'replicate' it on the PC by narrowing the browser window, by which the pictures disappear to the right, and there's no scroll bar at the bottom. I there any chance we could make the help pages phone-friendly? Best regards, Claus On 07.04.2020 10:54, Cl?ment David wrote: > Hello Federico, hello all, > > Thanks for pointing this, it looks like there is some missing URL redirect somewhere. > > google "help scilab datafit" on a private navigation tab redirect to the 5.3.3 help page whereas https://help.scilab.org/datafit looks OK. I will try to update the index to improve that, a related bug is #12746. See https://bugzilla.scilab.org/show_bug.cgi?id=12746 for more information and discussion on that topic, do not hesitate to contribute if you have some SEO knowledge. > > Thanks, > > -- > Cl?ment > >> -----Original Message----- >> From: users On Behalf Of Federico >> Miyara >> Sent: Tuesday, April 7, 2020 2:28 AM >> To: users at lists.scilab.org >> Subject: Re: [Scilab-users] question non datafit >> >> >> Samuel: >> >> Oh, this is embarrasing... I did a web search on non-linear fit and >> somehow the top results always point at an outdated version (5.5.2) of >> Scilab's documentation. I wonder why >> >> Thanks, the new documentation is much better! >> >> Regerds, >> >> Federico Miyara >> >> >> >> >> On 04/04/2020 06:58, Samuel Gougeon wrote: >> >> >> Le 04/04/2020 ? 09:26, Federico Miyara a ?crit : >> >> >> >> Dear All, >> >> I'm trying to understand the function datafit. >> >> The documentation says: >> >> >> >> datafit is used for fitting data to a model. For a given function >> G(p,z), this function finds the best vector of parameters p for >> approximating G(p,z_i)=0 for a set of measurement vectors z_i. Vector >> p is found by minimizing >> G(p,z_1)'WG(p,z_1)+G(p,z_2)'WG(p,z_2)+...+G(p,z_n)'WG(p,z_n) >> >> >> >> I don't quite understand what is G(p,z_1)'WG(p,z_1). Are some >> product signs * missing? Shouldn't it be G(p,z_1)'*W*G(p,z_1)? Are >> these signs implied as in regular algebra notation? >> >> >> >> >> >> Hello Federico, >> Please see the documentation of the latest scilab release: >> https://help.scilab.org/docs/6.1.0/en_US/datafit.html >> Regards >> >> >> >> >> >> >> _______________________________________________ >> 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 -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From sgougeon at free.fr Tue Apr 7 15:10:19 2020 From: sgougeon at free.fr (Samuel Gougeon) Date: Tue, 7 Apr 2020 15:10:19 +0200 Subject: [Scilab-users] question non datafit In-Reply-To: <414c4bfd-cd19-ceb6-e530-8967bd26e605@gmail.com> References: <528dc3ab-5c8d-cab1-a47d-cbaa73af95d8@free.fr> <0ead17fa-9a44-69d4-cbd9-84efdd63a9e2@fceia.unr.edu.ar> <414c4bfd-cd19-ceb6-e530-8967bd26e605@gmail.com> Message-ID: <58ea5768-884b-52ac-e139-fc08ed8d7c6f@free.fr> Le 07/04/2020 ? 15:06, Claus Futtrup a ?crit?: > Hi guys > > Since I'm interested in the topic, I decided to look up the link > (https://help.scilab.org/datafit) on my phone. > > I was unable to see the majority of the graphs on the right and I was > unable to zoom out. > > I am able to 'replicate' it on the PC by narrowing the browser window, > by which the pictures disappear to the right, and there's no scroll > bar at the bottom. > > I there any chance we could make the help pages phone-friendly? http://bugzilla.scilab.org/16381 From danielstringarita at gmail.com Wed Apr 8 03:48:51 2020 From: danielstringarita at gmail.com (Daniel Stringari) Date: Tue, 7 Apr 2020 18:48:51 -0700 (MST) Subject: [Scilab-users] spline and color plot on the chart Message-ID: <1586310531232-0.post@n3.nabble.com> Good night friends, I wrote an email before, but I believe that I was not clear in my words and so I will write more clearly. In this annex 1, I have the graph I am generating. Basically I am extracting values of x (speed) and y (torque) from excel and generating vectors of x [] and y [] to plot internal lines. I want to smooth these lines, but the functions of the scilab are only for growing points. I thought about creating cubic splines manually, but I don't know how to do it. Can anybody help me ? In addition, I would like to color my chart with level colors according to the colorbar, but I am not able to implement contour2d for this case. thanks. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From fmiyara at fceia.unr.edu.ar Wed Apr 8 05:53:43 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Wed, 8 Apr 2020 00:53:43 -0300 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: <1586310531232-0.post@n3.nabble.com> References: <1586310531232-0.post@n3.nabble.com> Message-ID: <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> Daniel, You may try with lsq_spline, which unlike ordinary spline, doesn't fit the data exactly, and it doesn't need the data with any particular order. But trying to understand your graph, it seems that you should parametrize two variables independently, each one with respect to the index. Something like this: x = [x1, x2, ..., xn] y = [y1, y2, ..., yn] Then you approximate x vs 1:n and y vs 1:n using spline or lsq_splin. Finally you plot xs vs ys (the smoothed versions of x and y) Regards, Federico Miyara On 07/04/2020 22:48, Daniel Stringari wrote: > Good night friends, > I wrote an email before, but I believe that I was not clear in my words and > so I will write more clearly. > > In this annex 1, I have the graph I am generating. Basically I am extracting > values of x (speed) and y (torque) from excel and generating vectors of x [] > and y [] to plot internal lines. I want to smooth these lines, but the > functions of the scilab are only for growing points. I thought about > creating cubic splines manually, but I don't know how to do it. Can anybody > help me ? > > In addition, I would like to color my chart with level colors according to > the colorbar, but I am not able to implement contour2d for this case. > > thanks. > > > > > > -- > Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmiyara at fceia.unr.edu.ar Wed Apr 8 05:59:50 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Wed, 8 Apr 2020 00:59:50 -0300 Subject: [Scilab-users] ?= Error in parameters determined in non-linear least-squares fittin In-Reply-To: <5079-5e8add00-11-15f56b20@211706307> References: <5079-5e8add00-11-15f56b20@211706307> Message-ID: <88b7e478-a546-96d1-a59e-2df85223c248@fceia.unr.edu.ar> Antoine, I find your tutorial very useful indeed! Regards, Federico Miyara On 06/04/2020 04:40, Antoine Monmayrant wrote: > Hi all, > > I would appreciate comments/corrections&improvements from you guys as I am far from a specialist in this field! > If some of you find this example useful, I can try to work a bit to improve it and push it as an atom module. > In fact, I have a bunch of other fit functions (like gaussian, diode-like curve, ...) that follow the same approach than the sinewave example and I've long wanted to bundle them in a module where one can add a new fit function by providing the model, error, jacobian and estimate functions like in my example... > > Antoine > > > Le Lundi, Avril 06, 2020 08:43 CEST, Claus Futtrup a ?crit: > >> Hi Scilabers >> >> Good examples are worth a lot. Maybe this one could be part of the >> Scilab documentation? >> >> Best regards, >> Claus >> >> On 06.04.2020 08:17, Antoine Monmayrant wrote: >>> Hello Heinz, >>> >>> See below the small example I built and I refer to whenever I need to do some data fitting with confidence intervals for the parameters of the model. >>> It is far from perfect but it might help you untangle the Jacobian and covariance matrix thingy. >>> Just two words of caution: (1) I am clearly less versed in applied maths than St?phane or Samuel, so take this with a grain of salft; (2) I built this example ages ago, before Samuel improved datafit. >>> >>> Good luck >>> >>> Antoine >>> >>> ////////////////////////////////////////////////////////////////////////////////////// >>> // REFERENCE: >>> // >>> // Least Squares Estimation >>> // SARA A. VAN DE GEER >>> // Volume 2, pp. 1041?1045 >>> // in >>> // Encyclopedia of Statistics in Behavioral Science >>> // ISBN-13: 978-0-470-86080-9 >>> // ISBN-10: 0-470-86080-4 >>> // Editors Brian S. Everitt & David C. Howell >>> // John Wiley & Sons, Ltd, Chichester, 2005 >>> // >>> >>> //This is a short and definetly incomplete tutorial on data fitting in Scilab using leastsq. >>> // >>> // Basic assumption: this tutorial is for scientists that face this simple problem: >>> // they have an experimental dataset x_epx,y_exp and a certain model y=Model(x,p) to fit thie dataset. >>> // This tutorial will try to answer the folowing questions: >>> // 1) how do you do that (simply) >>> // 2) how do you do that (more reliably and more quickly) >>> // a) let's go faster with a Jacobian >>> // b) how good is your fit? How big is the "error bar" associated with each parameter of your Model? >>> // c) Can we bullet proof it? >>> >>> //1) How do you do curve fitting in Scilab >>> // >>> // We need a) a model function b) a dataset c) some more work >>> // 1)a) Let's start with the model function: a sinewave >>> // here is the formula: y=A*sin(k*(x-x0))+y0; >>> // here is the function prototypr [y]=SineModel(x,p) with p=[x0,k,A,y0]' >>> function [y]=SineModel(x,p) >>> //INPUTS: x 1D vector >>> // p parameter vector of size [4,1] containing >>> // x0 : sine origin >>> // k : sine spatial frequency ie k=2%pi/Xp with Xp the period >>> // A : sine amplitude >>> // y0 : sine offset >>> //OUTPUTS: y 1D vector of same size than x such that y=A*sin(k*(x-x0))+y0; >>> x0=p(1); >>> k=p(2); >>> A=p(3); >>> y0=p(4); >>> y=y0+A*sin((x-x0)*k); >>> endfunction >>> >>> // 1)b) Let's now have a fake dataset: a sine wave with some noise >>> // We reuse the Model function we have just created to make this fake dataset >>> >>> x_exp=[-10:0.1:10]'; >>> x0=1.55; >>> k=1*%pi/3; >>> A=4.3; >>> y0=1.1 >>> y_exp=SineModel(x_exp,[x0,k,A,y0])+(2*rand(x_exp)-1)*6/10; >>> >>> //let's check and see what it looks like: >>> scf(); >>> plot(x_exp,y_exp,'k.-'); >>> xlabel('Exparimental X'); >>> ylabel('Exparimental Y'); >>> xtitle('Our fake experimental dataset to fit'); >>> >>> // 1)c) we are not done yet, we need some more work >>> // First we need an error function that return for a given parameter set param the difference >>> // between the experimental dataset and the model one: >>> // Note that this function returns the difference at each point, not the square of the difference, >>> // nor the sum over each point of the square of the differences >>> function e = ErrorFitSine(param, x_exp, y_exp) >>> e = SineModel(x_exp,param)-y_exp; >>> endfunction >>> // Now we need a starting point that is not too far away from the solution >>> // Let's just fo it by hand for the moment we'll see later how to make it programmatically >>> // Just go and have a look at the previous plot and "guess", here is mine: >>> p0=[1,2*%pi/6,4,1]; >>> >>> //Ready to go: >>> [f,popt, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); >>> //popt contains the optimal parameter set that fits our dataset >>> // >>> scf(); >>> plot(x_exp,y_exp,'k.'); >>> plot(x_exp,SineModel(x_exp,popt),'r-'); >>> xlabel('Experimental X') >>> ylabel('Experimental Y and best fit'); >>> xtitle([... >>> "x0="+msprintf('%1.3f fit value: \t%1.3f',x0,popt(1));... >>> "k ="+msprintf('%1.3f fit value: \t%1.3f',k,popt(2));... >>> "A ="+msprintf('%1.3f fit value: \t%1.3f',A,popt(3));... >>> "y0="+msprintf('%1.3f fit value: \t%1.3f',y0,popt(4))... >>> ]); >>> >>> //Yep we are done popt is the optimal parameter set that fits our dataset x_exp,y_exp with our >>> // model SineModel >>> // How to assert the quality of our fit? We can use fopt and gropt for that. They should be both as small as possible. >>> // Ideally, the gradient should be zeros for each parameter, otherwise it means we have not found an optimum. >>> >>> //2) How to go beyond that simple example? >>> // Namely: >>> // a) how to go faster? >>> // b) how to estimate how good our fit is (aka get error bars on our parameters)? >>> // c) how to make thinks more reliable with less human guessing and more bulletproofing? >>> >>> >>> //2)a) and also 2)b) >>> // We need the same extra function in order to speed things up and to estimate >>> // how the "noise" on the experimental dataset translates in "noise" on each >>> // individual parameter p(1), ...p($): the Jacobian matrix of our fit model. >>> // Impressive name for a simple idea: providing leastsq with the partial >>> // derivative of the model formula with respect to each parameter p(1)..p($). >>> function g = ErrorJMatSine(p, x, y) >>> // >>> >>> // g(1,:) = d(SinModel(x,p))/dx0 = d(SinModel(x,p))/d(p(1)) >>> // g(2,:) = d(SinModel(x,p))/dk = d(SinModel(x,p))/d(p(2)) >>> // g(3,:) = d(SinModel(x,p))/dA = d(SinModel(x,p))/d(p(3)) >>> // g(4,:) = d(SinModel(x,p))/dy0 = d(SinModel(x,p))/d(p(4)) >>> >>> // y=A*sin(k*(x-x0))+y0; >>> x0=p(1); >>> k=p(2); >>> A=p(3); >>> y0=p(4); >>> g = [... >>> (-k)*SineModel(x,[x0-%pi/2/k,k,A,0]'),... >>> (x-x0).*SineModel(x,[x0-%pi/2/k,k,A,0]'),... >>> SineModel(x,[x0,k,1,0]'),... >>> ones(x) ... >>> ]; >>> endfunction >>> >>> >>> //Ready to go again, and faster this time: >>> [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); >>> >>> disp("This should be ~ [0,0,0] when both fits give exactly the same results") >>> disp(string((popt-popt_fast)./(popt+popt_fast))) >>> >>> //Now we check that we are faster: >>> // we do it several times to average over timing variations caused by >>> // other processes running on our computer >>> speedup=zeros(1,10) >>> for i=1:100 >>> tic(); >>> [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),p0); >>> t1=toc(); >>> tic(); >>> [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); >>> t2=toc(); >>> speedup(i)=t1/t2; >>> end >>> >>> scf(); >>> plot(speedup,'k.'); >>> plot(mean(speedup)*ones(speedup),'r'); >>> xlabel("Fit iteration"); >>> ylabel("SpeedUp factor when using Jacobian Matrix"); >>> xtitle("Here we have a "+msprintf("~%1.2f",mean(speedup))+... >>> " speed improvement using the Jacobian Matrix"); >>> >>> //2)b) How can we estimate "error bars" for each individual parameters? >>> // We are going to estimate how the "noise" on our dataset turns into >>> // noise on each parameter by estimating the confidence interval at 95% >>> >>> g = ErrorJMatSine(popt_fast, x_exp, y_exp);//Jacobian matrix of the fit formula >>> //estimate of the initial noise on the dataset to fit >>> sigma2=1/(length(x_exp)-length(popt_fast))*f; >>> >>> //covariance matrix of fitting parameters >>> pcovar=inv(g'*g)*sigma2; >>> //confidence interval for each parameter >>> ci=(1.96*sqrt(diag(pcovar)))'; >>> >>> //Let's present the results of the confidence interval calculation >>> str=msprintf("%4.3f\n", popt_fast')+' +/- '+msprintf("%4.3f\n", ci'); >>> str=[["x0 = ";"k = ";"A = ";"y0 = "]+str]; >>> str=["Fit results:";"y=A*sin(k*(x-x0))+y0";"Param +/- conf. interval @ 95%";str] >>> >>> scf(); >>> plot(x_exp,y_exp,'k.'); >>> plot(x_exp,SineModel(x_exp,popt_fast),'r-'); >>> xlabel('Experimental X') >>> ylabel('Experimental Y and best fit'); >>> xtitle('Fit with confidence intervals at 95%'); >>> xstringb(-6,-3,str,12,6,'fill'); >>> e=gce(); >>> e.box="on"; >>> e.fill_mode="on"; >>> e.background=color("light gray"); >>> >>> //Now we have a fast fit function that can give some estimation on >>> // how seriously we can believe the fitted parameters. >>> // You can see that the precision with which we retrieve each parameter varies >>> // k0 is more precisely determined than y0 (15x more precisely!) >>> //You can play with the amount of noise to see how it affects the retrieved >>> // parameters and confidence intervals >>> >>> >>> >>> //2)b) How can we bullet proof our fitting script by putting all this stuff >>> // together is several functions that checks the arguments and modify >>> // them if needed to avoid difficult to understand complaints from >>> // leastsq? >>> >>> // test of a sinus fitting routine >>> >>> //// y=A*sin(k*(x-x0))+y0; >>> //// function [y]=Sine(x,x0,k,A,y0) >>> //// function [y]=Sine(x,p) with p=[x0,k,A,y0]' >>> //function [y]=Sine(x,varargin) >>> //// pause >>> // select length(varargin) >>> // case 1 then >>> // //we use form [y]=Sine(x,p) where p=[x0,dx,A,y0]' >>> // p=varargin(1); >>> // case 4 then >>> // //we use form [y]=Sine(x,x0,k,A,y0) >>> // p=[varargin(1);varargin(2);varargin(3);varargin(4)]; >>> // else >>> // //call is not correct, we give up >>> // y=[];return >>> // end >>> // x0=p(1); >>> // k=p(2); >>> // A=p(3); >>> // y0=p(4); >>> // y=y0+A*sin((x-x0)*k); >>> //endfunction >>> // >>> function [p0,pinf,psup]=EstimateFitSine(x,y) >>> // y=A*sin(k*(x-x0))+y0; >>> y0=mean(y); >>> A=(max(y)-min(y))/2; >>> // pause >>> sy=fftshift(fft(y-mean(y))); >>> //sy=fft(y-mean(y)); >>> msy=max(abs(sy));rg=find(abs(sy)==msy); >>> delta=(rg(2)-rg(1))/length(y); >>> k=delta*%pi/(mean(diff(x))); >>> x0=mean(abs(atan(imag(sy(rg)),real(sy(rg)))/k))+%pi/2/k; >>> p0=[x0,k,A,y0]; >>> pinf=[min(x),0 ,-%inf ,-%inf]; >>> psup=[max(x),%inf ,%inf ,%inf]; >>> endfunction >>> >>> >>> function e = ErrorFitSine(param, xi, yi) >>> e = SineModel(xi,param)-yi; >>> endfunction >>> >>> function g = dErrorFitSine(param, xi, yi) >>> // y=A*sin(k*(x-x0))+y0; >>> x0=param(1); >>> k=param(2); >>> A=param(3); >>> y0=param(4); >>> // pause >>> g = [... >>> (-k)*SineModel(xi,[x0-%pi/2/k,k,A,0]),... >>> (xi-x0).*SineModel(xi,[x0-%pi/2/k,k,A,0]),... >>> SineModel(xi,[x0,k,1,0]),... >>> ones(xi) ... >>> ]; >>> endfunction >>> >>> >>> >>> function [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0,varargin) >>> // FIT Experimental dataset y(x) with a sine model >>> // [y]=A*sin(k*(x-x0))+y0; >>> // >>> //INPUTS: >>> //x : experiemental x dataset >>> //y : experimental y dataset >>> //p0 : starting parameter set [x0,k,A,y0] >>> //varargin : >>> // pinf inferior limit for popt >>> // psup superior limit for popt >>> //OUTPUTS >>> //f : value of the cost function for the best parameter set >>> //popt : best parameter set >>> //yopt : fit function evaluated on the x dataset >>> //gropt : gradient of the cost function at x >>> //ci ; confidence interval @ 95% on each parameter in popt >>> //pcovar ; covariance matrix of popt >>> >>> // CHECK x and y are col not row >>> if isrow(x) then >>> x=x.'; >>> end >>> if isrow(y) then >>> y=y.'; >>> end >>> >>> if (length(varargin) < 2) then >>> // No constraints on parameter set were provided >>> [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,p0); >>> // [f,popt_fast, gropt] = leastsq(list(ErrorFitSine,x_exp,y_exp),ErrorJMatSine,p0); >>> else >>> // Constraints on parameter set were provided >>> pinf=varargin(1); >>> psup=varargin(2); >>> [f,popt, gropt] = leastsq(list(ErrorFitSine,x,y),dErrorFitSine,"b",pinf,psup,p0); >>> end >>> //normalized best fit evaluated on normalized x >>> yopt=ErrorFitSine(popt, x, zeros(x)); >>> //rescale best fit param >>> >>> g = dErrorFitSine(popt, x, y);//Jacobian matrix of the fit formula >>> //estimate of the noise on the signal to fit >>> sigma2=1/(length(x)-length(popt))*f; >>> >>> //covariance matrix of fitting parameters >>> pcovar=inv(g'*g)*sigma2; >>> //confidence interval for each parameter >>> ci=1.96*sqrt(diag(pcovar)); >>> ci=ci.'; >>> endfunction >>> >>> >>> // Let's use our unified and bullet-proof routine >>> >>> x=[-10:0.1:10]; >>> //y=Sine(x,[1,2*%pi/3,4,1])+(2*rand(x)-1)*0.1; >>> y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2; >>> //y=SineModel(x,[5,1*%pi/3,4,1])+(2*rand(x)-1)*2/10; >>> >>> p0=EstimateFitSine(x,y); >>> [f,popt,yopt,gropt,ci,pcovar]=FitSine(x,y,p0); >>> >>> >>> str="$"+["x_0";"k";"A";"y_0"]+"="+string(popt.')+"\pm"+string(ci.')+"$"; >>> str=["$\text{Model: }[y]=A\sin(k(x-x_0))+y_0$";str]; >>> >>> scf(); >>> plot(x,y,'k.'); >>> plot(x,SineModel(x,p0),'g'); >>> plot(x,SineModel(x,popt),'r'); >>> xlabel("$x$"); >>> ylabel("$y$"); >>> xtitle(str) >>> legend(["Data";"Guess";"Fit"]) >>> >>> ////////////////////////////////////////////////////////////////////////////////////// >>> >>> Le Samedi, Avril 04, 2020 15:13 CEST, Heinz Nabielek a ?crit: >>> >>>> Scilab friends: the power of Scilab is amazing and I have used it recently for non-linear least-squares fitting, below example from Scilab help function for "datafit". On occasions, I have also used "leastsq". >>>> >>>> Question: how do I derive the 1sigma standard error in the three parameters p(1), p(2), and p(3)? And, if it is not too complicated, covariances? >>>> >>>> I know this is written in dozens of textbooks, but I am always getting lost. >>>> Please provide a simple recipe written in Scilab. >>>> Best greetings >>>> Heinz >>>> >>>> >>>> >>>> // -- 04/04/2020 14:57:30 -- // >>>> //generate the data >>>> function y=FF(x, p) >>>> y=p(1)*(x-p(2))+p(3)*x.*x >>>> endfunction >>>> X=[]; >>>> Y=[]; >>>> pg=[34;12;14] //parameter used to generate data >>>> for x=0:.1:3 >>>> Y=[Y,FF(x,pg)+100*(rand()-.5)]; >>>> X=[X,x]; >>>> end >>>> Z=[Y;X]; >>>> //The criterion function >>>> function e=G(p, z), >>>> y=z(1),x=z(2); >>>> e=y-FF(x,p), >>>> endfunction >>>> //Solve the problem >>>> p0=[3;5;10] >>>> [p,err]=datafit(G,Z,p0); >>>> scf(0);clf() >>>> plot2d(X,FF(X,pg),5) //the curve without noise >>>> plot2d(X,Y,-1) // the noisy data >>>> plot2d(X,FF(X,p),12) //the solution >>>> xgrid();legend("the curve without noise"," the noisy data", "THE FINAL SOLUTION.....",4); >>>> title("solution set 39.868419 10.312053 11.482521","fontsize",4); >>> _______________________________________________ >>> users mailing list >>> users at lists.scilab.org >>> http://lists.scilab.org/mailman/listinfo/users >> >> >> -- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus >> >> _______________________________________________ >> 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jrafaelbguerra at hotmail.com Fri Apr 10 09:46:00 2020 From: jrafaelbguerra at hotmail.com (Rafael Guerra) Date: Fri, 10 Apr 2020 07:46:00 +0000 Subject: [Scilab-users] printf "\r" in Scilab 6x Message-ID: Dear Scilab'ers, The following code, when executed from SciNotes in Scilab 5x, printed the loop progress to console, at same location, thanks to printf ("\r"). The printf behaviour seems to have changed in Scilab 6x, and the strings are now printed one after the other. printf("Print loop progress at same place in console (was OK in Scilab 5x):\n"); N = 1e5; j=1; for i=1:N if modulo(i,int(N/10))==0 then // Print progress by steps of 10% printf("Progress = %i%s\r",j*10,"%"); // carriage return, prints at same place on console j=j+1; end end Is it still possible to print at same place to console in Scilab 6x? Regards, Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From sgougeon at free.fr Fri Apr 10 10:35:32 2020 From: sgougeon at free.fr (Samuel Gougeon) Date: Fri, 10 Apr 2020 10:35:32 +0200 Subject: [Scilab-users] printf "\r" in Scilab 6x In-Reply-To: References: Message-ID: Le 10/04/2020 ? 09:46, Rafael Guerra a ?crit?: > > Dear Scilab?ers, > > The following code, when executed from SciNotes in Scilab 5x, printed > the loop progress to console, at same location, thanks to? printf ("\r"). > > The printf behaviour seems to have changed in Scilab 6x, and the > strings are now printed one after the other. > > printf("Print loop progress at same place in console (was OK in Scilab > 5x):\n"); > > N= 1e5; > j=1; > fori=1:N > if _modulo_(i,int(N/10))==0 then /// Print progress by steps of 10%/ > printf("Progress = %i%s\r",j*10,"%"); /// carriage return, prints at > same place on console/ > j=j+1; > end > end > Please see http://mailinglists.scilab.org/Scilab-users-Scilab-API-sciprint-to-print-on-the-same-line-td4040189.html#a4040193 and http://bugzilla.scilab.org/14342 and for i = 1:12, mprintf("Progress = %d\n\n", i); sleep(2000); clc(0); end -------------- next part -------------- An HTML attachment was scrubbed... URL: From jrafaelbguerra at hotmail.com Fri Apr 10 10:50:20 2020 From: jrafaelbguerra at hotmail.com (Rafael Guerra) Date: Fri, 10 Apr 2020 08:50:20 +0000 Subject: [Scilab-users] printf "\r" in Scilab 6x In-Reply-To: References: Message-ID: Great thanks. Using clc(0) solves it, clearing current line in the Command window. It works both for printf and mprintf. Maybe some generous soul could add this example to the 'clc' help entry? From: users On Behalf Of Samuel Gougeon Sent: Friday, April 10, 2020 11:36 AM To: users at lists.scilab.org Subject: Re: [Scilab-users] printf "\r" in Scilab 6x Le 10/04/2020 ? 09:46, Rafael Guerra a ?crit : Dear Scilab'ers, The following code, when executed from SciNotes in Scilab 5x, printed the loop progress to console, at same location, thanks to printf ("\r"). The printf behaviour seems to have changed in Scilab 6x, and the strings are now printed one after the other. Please see http://mailinglists.scilab.org/Scilab-users-Scilab-API-sciprint-to-print-on-the-same-line-td4040189.html#a4040193 and http://bugzilla.scilab.org/14342 and for i = 1:12, mprintf("Progress = %d\n\n", i); sleep(2000); clc(0); end -------------- next part -------------- An HTML attachment was scrubbed... URL: From j-lan at online.no Fri Apr 10 14:57:01 2020 From: j-lan at online.no (=?UTF-8?Q?Jan_=c3=85ge_Langeland?=) Date: Fri, 10 Apr 2020 14:57:01 +0200 Subject: [Scilab-users] printf "\r" in Scilab 6x In-Reply-To: References: Message-ID: <8fd2f08b-ab8d-51f8-3dc3-733814fc001b@online.no> In 6.0.2 I find I need to use: for i = 1:12, mprintf("Progress = %d\n\n\n", i); sleep(2000); clc(1); end J? On 2020-04-10 10:50 AM, Rafael Guerra wrote: > for i = 1:12, mprintf("Progress = %d\n\n", i); sleep(2000); clc(0); end From fmiyara at fceia.unr.edu.ar Fri Apr 10 15:28:20 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Fri, 10 Apr 2020 10:28:20 -0300 Subject: [Scilab-users] Incorrect color in function Message-ID: <5ef41d9a-56bf-4759-e13e-f8d2538a9556@fceia.unr.edu.ar> Dear all, When writing the following script in SciNotes (v. 6.1): function y = testcolor(t) ??? if 1==1 ??????? y = sinc(t) ??????? plot(t, y) ??????? legend("sinc") ??? else ??????? y = 1 ??? end endfunction the end of the if structure appears with the same brownish color as the endfunction. Strangely, if copying and pasting here or into a word processor document, the color is the expected purple (that's why I removed all colors in this message). It seems that the culprit is the legend clause. Regards, Federico Miyara From amonmayr at laas.fr Fri Apr 10 16:03:55 2020 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Fri, 10 Apr 2020 16:03:55 +0200 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ICBJbmNvcnJlY3QgY29sb3Ig?= =?utf-8?q?in_function?= In-Reply-To: <5ef41d9a-56bf-4759-e13e-f8d2538a9556@fceia.unr.edu.ar> Message-ID: <1c33-5e907d00-43-59e90d80@164182252> Hello, It seems that you're missing a "then" but nonetheless, the problem is really related to legend(), wich is weird. I can reproduce your color bug with function a() if %t then plot() else legend() end endfunction but not with function a() if %t then plot() else legen() end endfunction (only difference legend()->legen()). Antoine Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: > > Dear all, > > When writing the following script in SciNotes (v. 6.1): > > function y = testcolor(t) > ??? if 1==1 > ??????? y = sinc(t) > ??????? plot(t, y) > ??????? legend("sinc") > ??? else > ??????? y = 1 > ??? end > endfunction > > the end of the if structure appears with the same brownish color as the > endfunction. Strangely, if copying and pasting here or into a word > processor document, the color is the expected purple (that's why I > removed all colors in this message). > > It seems that the culprit is the legend clause. > > Regards, > > Federico Miyara > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From amonmayr at laas.fr Fri Apr 10 16:09:26 2020 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Fri, 10 Apr 2020 16:09:26 +0200 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ICBJbmNvcnJlY3QgY29sb3Ig?= =?utf-8?q?in_function?= In-Reply-To: <5ef41d9a-56bf-4759-e13e-f8d2538a9556@fceia.unr.edu.ar> Message-ID: <32a4-5e907e00-3b-1a2f16c0@40017498> OK, I think I nailed it: function a() if % then end() end endfunction It's the "end()" in "legend()" that sends the parser off the trail: it thinks that the if block is over (as it has found "if", "then" & leg"end"() ) and then treats the next "end" as matching the "function" Antoine Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: > > Dear all, > > When writing the following script in SciNotes (v. 6.1): > > function y = testcolor(t) > ??? if 1==1 > ??????? y = sinc(t) > ??????? plot(t, y) > ??????? legend("sinc") > ??? else > ??????? y = 1 > ??? end > endfunction > > the end of the if structure appears with the same brownish color as the > endfunction. Strangely, if copying and pasting here or into a word > processor document, the color is the expected purple (that's why I > removed all colors in this message). > > It seems that the culprit is the legend clause. > > Regards, > > Federico Miyara > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From cfuttrup at gmail.com Fri Apr 10 16:17:00 2020 From: cfuttrup at gmail.com (Claus Futtrup) Date: Fri, 10 Apr 2020 16:17:00 +0200 Subject: [Scilab-users] ?==?utf-8?q? Incorrect color in function In-Reply-To: <32a4-5e907e00-3b-1a2f16c0@40017498> References: <32a4-5e907e00-3b-1a2f16c0@40017498> Message-ID: <952464c8-89a7-10d1-56a6-597977b72405@gmail.com> HA HA :-D ... it's funny! Cheers, Claus On 10.04.2020 16:09, Antoine Monmayrant wrote: > OK, I think I nailed it: > > function a() > if % then > end() > end > endfunction > > It's the "end()" in "legend()" that sends the parser off the trail: it thinks that the if block is over (as it has found "if", "then" & leg"end"() ) and then treats the next "end" as matching the "function" > > Antoine > > > Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: > >> Dear all, >> >> When writing the following script in SciNotes (v. 6.1): >> >> function y = testcolor(t) >> ??? if 1==1 >> ??????? y = sinc(t) >> ??????? plot(t, y) >> ??????? legend("sinc") >> ??? else >> ??????? y = 1 >> ??? end >> endfunction >> >> the end of the if structure appears with the same brownish color as the >> endfunction. Strangely, if copying and pasting here or into a word >> processor document, the color is the expected purple (that's why I >> removed all colors in this message). >> >> It seems that the culprit is the legend clause. >> >> Regards, >> >> Federico Miyara >> >> _______________________________________________ >> 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 -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus From amonmayr at laas.fr Fri Apr 10 16:43:45 2020 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Fri, 10 Apr 2020 16:43:45 +0200 Subject: [Scilab-users] =?utf-8?b?Pz09P3V0Zi04P3E/ID89PT91dGYtOD9xPyA/PSAg?= =?utf-8?q?Incorrect_color_in_functio?= In-Reply-To: <952464c8-89a7-10d1-56a6-597977b72405@gmail.com> Message-ID: <28c8-5e908600-47-7153dd80@198158176> Yes, quite funny if we write it that way: //////////////////////////////// function a() if %t then what_ever_you_want_that_ends_with_end end endfunction function b() if %t then or_that_ends_with_end() end endfunction //////////////////////////////// Frederico, do you think you could fill a bug report? Cheers, Antoine Le Vendredi, Avril 10, 2020 16:17 CEST, Claus Futtrup a ?crit: > > HA HA :-D ... it's funny! > > Cheers, > Claus > > On 10.04.2020 16:09, Antoine Monmayrant wrote: > > OK, I think I nailed it: > > > > function a() > > if % then > > end() > > end > > endfunction > > > > It's the "end()" in "legend()" that sends the parser off the trail: it thinks that the if block is over (as it has found "if", "then" & leg"end"() ) and then treats the next "end" as matching the "function" > > > > Antoine > > > > > > Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: > > > >> Dear all, > >> > >> When writing the following script in SciNotes (v. 6.1): > >> > >> function y = testcolor(t) > >> ??? if 1==1 > >> ??????? y = sinc(t) > >> ??????? plot(t, y) > >> ??????? legend("sinc") > >> ??? else > >> ??????? y = 1 > >> ??? end > >> endfunction > >> > >> the end of the if structure appears with the same brownish color as the > >> endfunction. Strangely, if copying and pasting here or into a word > >> processor document, the color is the expected purple (that's why I > >> removed all colors in this message). > >> > >> It seems that the culprit is the legend clause. > >> > >> Regards, > >> > >> Federico Miyara > >> > >> _______________________________________________ > >> 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 > > > > -- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > From stephane.mottelet at utc.fr Fri Apr 10 16:46:46 2020 From: stephane.mottelet at utc.fr (=?utf-8?Q?St=C3=A9phane_Mottelet?=) Date: Fri, 10 Apr 2020 16:46:46 +0200 Subject: [Scilab-users] ?= Incorrect color in functio In-Reply-To: <28c8-5e908600-47-7153dd80@198158176> References: <28c8-5e908600-47-7153dd80@198158176> Message-ID: <9A9BD3BB-3415-43F4-9A04-1C11180F4885@utc.fr> Hello all, > Le 10 avr. 2020 ? 16:44, Antoine Monmayrant a ?crit : > > ?Yes, quite funny if we write it that way: > > //////////////////////////////// > function a() > if %t then > what_ever_you_want_that_ends_with_end > end > endfunction > > function b() > if %t then > or_that_ends_with_end() > end > endfunction > //////////////////////////////// > > Frederico, do you think you could fill a bug report? Yes ! S. > > Cheers, > > Antoine > > Le Vendredi, Avril 10, 2020 16:17 CEST, Claus Futtrup a ?crit: > >> >> HA HA :-D ... it's funny! >> >> Cheers, >> Claus >> >>> On 10.04.2020 16:09, Antoine Monmayrant wrote: >>> OK, I think I nailed it: >>> >>> function a() >>> if % then >>> end() >>> end >>> endfunction >>> >>> It's the "end()" in "legend()" that sends the parser off the trail: it thinks that the if block is over (as it has found "if", "then" & leg"end"() ) and then treats the next "end" as matching the "function" >>> >>> Antoine >>> >>> >>> Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: >>> >>>> Dear all, >>>> >>>> When writing the following script in SciNotes (v. 6.1): >>>> >>>> function y = testcolor(t) >>>> if 1==1 >>>> y = sinc(t) >>>> plot(t, y) >>>> legend("sinc") >>>> else >>>> y = 1 >>>> end >>>> endfunction >>>> >>>> the end of the if structure appears with the same brownish color as the >>>> endfunction. Strangely, if copying and pasting here or into a word >>>> processor document, the color is the expected purple (that's why I >>>> removed all colors in this message). >>>> >>>> It seems that the culprit is the legend clause. >>>> >>>> Regards, >>>> >>>> Federico Miyara >>>> >>>> _______________________________________________ >>>> 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 >> >> >> >> -- >> This email has been checked for viruses by Avast antivirus software. >> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.avast.com/antivirus >> >> _______________________________________________ >> 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 fmiyara at fceia.unr.edu.ar Fri Apr 10 18:15:35 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Fri, 10 Apr 2020 13:15:35 -0300 Subject: [Scilab-users] ?==?utf-8?q? Incorrect color in function In-Reply-To: <1c33-5e907d00-43-59e90d80@164182252> References: <1c33-5e907d00-43-59e90d80@164182252> Message-ID: <3d961ca0-ce62-49f4-c922-a9c0e6730dff@fceia.unr.edu.ar> Antoine, I prefer the syntax without "then", it works, it is supported and the "then" seems redundant, but as you say, it is not related to that. Thanks, Federico Miyara On 10/04/2020 11:03, Antoine Monmayrant wrote: > Hello, > > It seems that you're missing a "then" but nonetheless, the problem is really related to legend(), wich is weird. > I can reproduce your color bug with > > function a() > if %t then > plot() > else > legend() > end > endfunction > > > but not with > > function a() > if %t then > plot() > else > legen() > end > endfunction > > (only difference legend()->legen()). > > Antoine > > Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: > >> Dear all, >> >> When writing the following script in SciNotes (v. 6.1): >> >> function y = testcolor(t) >> ??? if 1==1 >> ??????? y = sinc(t) >> ??????? plot(t, y) >> ??????? legend("sinc") >> ??? else >> ??????? y = 1 >> ??? end >> endfunction >> >> the end of the if structure appears with the same brownish color as the >> endfunction. Strangely, if copying and pasting here or into a word >> processor document, the color is the expected purple (that's why I >> removed all colors in this message). >> >> It seems that the culprit is the legend clause. >> >> Regards, >> >> Federico Miyara >> >> _______________________________________________ >> 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From perrichon.pierre at wanadoo.fr Fri Apr 10 18:28:49 2020 From: perrichon.pierre at wanadoo.fr (Perrichon) Date: Fri, 10 Apr 2020 18:28:49 +0200 Subject: [Scilab-users] ?==?utf-8?q? Incorrect color in function In-Reply-To: <3d961ca0-ce62-49f4-c922-a9c0e6730dff@fceia.unr.edu.ar> References: <1c33-5e907d00-43-59e90d80@164182252> <3d961ca0-ce62-49f4-c922-a9c0e6730dff@fceia.unr.edu.ar> Message-ID: Indeed. Isn?t it, but ::: Coming fron 5.x to 6.x, logical and in 5x is ? & ? and, like in C ? && ? in 6x. So a pass is needed in all hundred of files to provide to clients, phonecontact, documentation, and so on ? great, thank you so much ; I think it?s more important than ? then ? instruction. Regards De : users De la part de Federico Miyara Envoy? : vendredi 10 avril 2020 18:16 ? : users at lists.scilab.org Objet : Re: [Scilab-users] ?==?utf-8?q? Incorrect color in function Antoine, I prefer the syntax without "then", it works, it is supported and the "then" seems redundant, but as you say, it is not related to that. Thanks, Federico Miyara On 10/04/2020 11:03, Antoine Monmayrant wrote: Hello, It seems that you're missing a "then" but nonetheless, the problem is really related to legend(), wich is weird. I can reproduce your color bug with function a() if %t then plot() else legend() end endfunction but not with function a() if %t then plot() else legen() end endfunction (only difference legend()->legen()). Antoine Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: Dear all, When writing the following script in SciNotes (v. 6.1): function y = testcolor(t) if 1==1 y = sinc(t) plot(t, y) legend("sinc") else y = 1 end endfunction the end of the if structure appears with the same brownish color as the endfunction. Strangely, if copying and pasting here or into a word processor document, the color is the expected purple (that's why I removed all colors in this message). It seems that the culprit is the legend clause. Regards, Federico Miyara _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmiyara at fceia.unr.edu.ar Fri Apr 10 18:47:48 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Fri, 10 Apr 2020 13:47:48 -0300 Subject: [Scilab-users] ?= Incorrect color in functio In-Reply-To: <28c8-5e908600-47-7153dd80@198158176> References: <28c8-5e908600-47-7153dd80@198158176> Message-ID: Antoine, Yes, I've filed it as https://bugzilla.scilab.org/show_bug.cgi?id=16405 Regards, Federico Miyara On 10/04/2020 11:43, Antoine Monmayrant wrote: > Yes, quite funny if we write it that way: > > //////////////////////////////// > function a() > if %t then > what_ever_you_want_that_ends_with_end > end > endfunction > > function b() > if %t then > or_that_ends_with_end() > end > endfunction > //////////////////////////////// > > Frederico, do you think you could fill a bug report? > > Cheers, > > Antoine > > Le Vendredi, Avril 10, 2020 16:17 CEST, Claus Futtrup a ?crit: > >> HA HA :-D ... it's funny! >> >> Cheers, >> Claus >> >> On 10.04.2020 16:09, Antoine Monmayrant wrote: >>> OK, I think I nailed it: >>> >>> function a() >>> if % then >>> end() >>> end >>> endfunction >>> >>> It's the "end()" in "legend()" that sends the parser off the trail: it thinks that the if block is over (as it has found "if", "then" & leg"end"() ) and then treats the next "end" as matching the "function" >>> >>> Antoine >>> >>> >>> Le Vendredi, Avril 10, 2020 15:28 CEST, Federico Miyara a ?crit: >>> >>>> Dear all, >>>> >>>> When writing the following script in SciNotes (v. 6.1): >>>> >>>> function y = testcolor(t) >>>> ??? if 1==1 >>>> ??????? y = sinc(t) >>>> ??????? plot(t, y) >>>> ??????? legend("sinc") >>>> ??? else >>>> ??????? y = 1 >>>> ??? end >>>> endfunction >>>> >>>> the end of the if structure appears with the same brownish color as the >>>> endfunction. Strangely, if copying and pasting here or into a word >>>> processor document, the color is the expected purple (that's why I >>>> removed all colors in this message). >>>> >>>> It seems that the culprit is the legend clause. >>>> >>>> Regards, >>>> >>>> Federico Miyara >>>> >>>> _______________________________________________ >>>> 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 >> >> >> -- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus >> >> _______________________________________________ >> 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 danielstringarita at gmail.com Sat Apr 11 02:05:57 2020 From: danielstringarita at gmail.com (Daniel Stringari) Date: Fri, 10 Apr 2020 21:05:57 -0300 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> References: <1586310531232-0.post@n3.nabble.com> <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> Message-ID: Federico, I appreciate the help. Below is a list of the code on which I try to plot the data with Isq_splin: c = size (vt12) a = 0 b = c (1) // c (1) = 16 n = c (1) x = linspace (a, b, n) [y, d] = lsq_splin (vt12, vv12, x ') plot (y, d, 'r') xlabel ('Speed (rpm)') ylabel ('Torque (Nm)') title ('Torque x speed values') //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57 3602.73 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49 6232.1 //vv12 = 40.16 39.93 39.71 39.49 69.04 68.54 95.32 119.26 140.49 139.32 155.62 154.37 93.27 92.82 92.38 91.94 but I'm getting the error: lsq_plin: There are not enough points to adjust. Does anyone understand what could be wrong? On Wed, Apr 8, 2020 at 12:54 AM Federico Miyara wrote: > > Daniel, > > You may try with lsq_spline, which unlike ordinary spline, doesn't fit the > data exactly, and it doesn't need the data with any particular order. > > But trying to understand your graph, it seems that you should parametrize > two variables independently, each one with respect to the index. Something > like this: > > x = [x1, x2, ..., xn] > y = [y1, y2, ..., yn] > > Then you approximate x vs 1:n and y vs 1:n using spline or lsq_splin. > Finally you plot xs vs ys (the smoothed versions of x and y) > > Regards, > > Federico Miyara > > > On 07/04/2020 22:48, Daniel Stringari wrote: > > Good night friends, > I wrote an email before, but I believe that I was not clear in my words and > so I will write more clearly. > > In this annex 1, I have the graph I am generating. Basically I am extracting > values of x (speed) and y (torque) from excel and generating vectors of x [] > and y [] to plot internal lines. I want to smooth these lines, but the > functions of the scilab are only for growing points. I thought about > creating cubic splines manually, but I don't know how to do it. Can anybody > help me ? > > In addition, I would like to color my chart with level colors according to > the colorbar, but I am not able to implement contour2d for this case. > > thanks. > > > > > -- > Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html > _______________________________________________ > users mailing listusers at lists.scilab.orghttp://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: From fmiyara at fceia.unr.edu.ar Sat Apr 11 05:51:47 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Sat, 11 Apr 2020 00:51:47 -0300 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: References: <1586310531232-0.post@n3.nabble.com> <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> Message-ID: Daniel: I think you meant to include more than 1 point. You seem to have confused the dimensions given by function size. But anyway this doesn't seem to be what I suggested. You should compute a spline for vt12 vs x (the right x, using b = c(2)) and another one for vv12. You don't need in this case to use lsq_splin, but in case you want to use it, the third argument has usually less points than the other two, for instance [yvt, dvt] = lsq_splin (x, vt12, linspace(a, b, 8)) The output argumnts should be used in interp,as shown in the lsq_splin help. Once you have a smoothed version of vt12_s vs x_s and of vv12_s vs x_s you plot vv12_s vs vt12_s Regards, Federico Miyara On 10/04/2020 21:05, Daniel Stringari wrote: > c = size (vt12) > a = 0 > b = c (1) // c (1) = 16 > n = c (1) > x = linspace (a, b, n) > [y, d] = lsq_splin (vt12, vv12, x ') > plot (y, d, 'r') > xlabel ('Speed (rpm)') > ylabel ('Torque (Nm)') > title ('Torque x speed values') > > //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57 3602.73 > 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49 6232.1 > //vv12 = 40.16 ? 39.93 ? 39.71 ? 39.49 ? 69.04 ? 68.54 ? 95.32 119.26 > ? 140.49 ? 139.32 ? 155.62 ? 154.37 ? 93.27 ? 92.82 ? 92.38 ? 91.94 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jrafaelbguerra at hotmail.com Sat Apr 11 11:10:38 2020 From: jrafaelbguerra at hotmail.com (Rafael Guerra) Date: Sat, 11 Apr 2020 09:10:38 +0000 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: References: <1586310531232-0.post@n3.nabble.com> <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> Message-ID: Reading the lsq_splin function help, should help in this case: The error ?There are not enough points to adjust? is due to the fact that the 3rd input to lsq_splin (?x? the list of breakpoints of the cubic spline) has values all lying outside the input vt12 variable range (39.49 to 155.62). From: users On Behalf Of Daniel Stringari Sent: Saturday, April 11, 2020 3:06 AM To: Users mailing list for Scilab Subject: Re: [Scilab-users] spline and color plot on the chart Federico, I appreciate the help. Below is a list of the code on which I try to plot the data with Isq_splin: c = size (vt12) a = 0 b = c (1) // c (1) = 16 n = c (1) x = linspace (a, b, n) [y, d] = lsq_splin (vt12, vv12, x ') plot (y, d, 'r') xlabel ('Speed (rpm)') ylabel ('Torque (Nm)') title ('Torque x speed values') //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57 3602.73 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49 6232.1 //vv12 = 40.16 39.93 39.71 39.49 69.04 68.54 95.32 119.26 140.49 139.32 155.62 154.37 93.27 92.82 92.38 91.94 but I'm getting the error: lsq_plin: There are not enough points to adjust. Does anyone understand what could be wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmiyara at fceia.unr.edu.ar Sun Apr 12 02:17:27 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Sat, 11 Apr 2020 21:17:27 -0300 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: References: <1586310531232-0.post@n3.nabble.com> <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> Message-ID: <705465a5-e55f-5312-f57a-13fb3e86d86c@fceia.unr.edu.ar> Daniel, I'm afraid I was a bit confused with your application case. I assumed that there was an independent variable such as time or other which the other two, vt12 and vv12, depend on. If this were the case, the expected graph could be a curve or rather a trajectory with some hysteresis. But if your data are just measurements in no particular order of what is a functional relation of one variable respect to the other, for instance vt12 = f(vv12), then the approach is different. You should basically sort the independent variable in increasing order using gsort and apply the same sorting to the dependent variable: [x, I] = gsort(vv12,"g","i"); y = vt12(I); Then you can proceed to interpolate with spline or lsg_splin. Regards, Federico Miyara On 10/04/2020 21:05, Daniel Stringari wrote: > Federico, > > I appreciate the help. Below is a list of the code on which I try to > plot the data with Isq_splin: > > c = size (vt12) > a = 0 > b = c (1) // c (1) = 16 > n = c (1) > x = linspace (a, b, n) > [y, d] = lsq_splin (vt12, vv12, x ') > plot (y, d, 'r') > xlabel ('Speed (rpm)') > ylabel ('Torque (Nm)') > title ('Torque x speed values') > > //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57 3602.73 > 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49 6232.1 > //vv12 = 40.16 ? 39.93 ? 39.71 ? 39.49 ? 69.04 ? 68.54 ? 95.32 119.26 > ? 140.49 ? 139.32 ? 155.62 ? 154.37 ? 93.27 ? 92.82 92.38 ? 91.94 > > but I'm getting the error: lsq_plin: There are not enough points to > adjust. > > Does anyone understand what could be wrong? > > On Wed, Apr 8, 2020 at 12:54 AM Federico Miyara > > wrote: > > > Daniel, > > You may try with lsq_spline, which unlike ordinary spline, doesn't > fit the data exactly, and it doesn't need the data with any > particular order. > > But trying to understand your graph, it seems that you should > parametrize two variables independently, each one with respect to > the index. Something like this: > > x = [x1, x2, ..., xn] > y = [y1, y2, ..., yn] > > Then you approximate x vs 1:n and y vs 1:n using spline or > lsq_splin. Finally you plot xs vs ys (the smoothed versions of x > and y) > > Regards, > > Federico Miyara > > > On 07/04/2020 22:48, Daniel Stringari wrote: >> Good night friends, >> I wrote an email before, but I believe that I was not clear in my words and >> so I will write more clearly. >> >> In this annex 1, I have the graph I am generating. Basically I am extracting >> values of x (speed) and y (torque) from excel and generating vectors of x [] >> and y [] to plot internal lines. I want to smooth these lines, but the >> functions of the scilab are only for growing points. I thought about >> creating cubic splines manually, but I don't know how to do it. Can anybody >> help me ? >> >> In addition, I would like to color my chart with level colors according to >> the colorbar, but I am not able to implement contour2d for this case. >> >> thanks. >> >> >> >> >> >> -- >> Sent from:http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html >> _______________________________________________ >> 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 > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielstringarita at gmail.com Sun Apr 12 02:45:07 2020 From: danielstringarita at gmail.com (Daniel Stringari) Date: Sat, 11 Apr 2020 21:45:07 -0300 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: <705465a5-e55f-5312-f57a-13fb3e86d86c@fceia.unr.edu.ar> References: <1586310531232-0.post@n3.nabble.com> <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> <705465a5-e55f-5312-f57a-13fb3e86d86c@fceia.unr.edu.ar> Message-ID: Federico, I am extracting the values of the vectors (vv12 and vt12) from a logic in which it takes data from a spreadsheet that was generated using specific software. The vectors (vv12 and vt12) represent an efficiency curve within the torque x speed plane, I have eleven more of these vectors that vary in size. I believe that I do not have a role in which one depends on the other directly. I tried to follow your first reasoning and arrived at a routine that does not report errors but is not smoothing my curve either, follow the routine: clcclearvt12 = [5350.3,5380.19,5410.08,5439.96,4149.5,4179.35,3756.57,3602.73,3568.12,3597.85,3681.91,3711.59,6143.24,6172.86,6202.49,6232.1]vv12 = [40.16,39.93,39.71,39.49,69.04,68.54,95.32,119.26,140.49,139.32,155.62,154.37,93.27,92.82,92.38,91.94] c = size (vt12)a = 1b = c(2)n = c(2)x = linspace (a, b, n) [yvt,dvt] = lsq_splin(x,vt12,linspace (a,b,n))[yvv,dvv] = lsq_splin(x,vv12,linspace (a,b,n)) ys=interp(linspace (a,b,n),linspace (a,b,n),yvt,dvt)xs=interp(linspace (a,b,n),linspace (a,b,n),yvv,dvv) plot (ys,xs,'r')xlabel ('Speed (rpm)')ylabel ('Torque (Nm)')title ('Torque x speed values') Any idea how I can proceed with my goal of smoothing the curve to use the color map later? On Sat, Apr 11, 2020 at 9:18 PM Federico Miyara wrote: > > Daniel, > > I'm afraid I was a bit confused with your application case. > > I assumed that there was an independent variable such as time or other > which the other two, vt12 and vv12, depend on. If this were the case, the > expected graph could be a curve or rather a trajectory with some hysteresis. > > But if your data are just measurements in no particular order of what is a > functional relation of one variable respect to the other, for instance vt12 > = f(vv12), then the approach is different. You should basically sort the > independent variable in increasing order using gsort and apply the same > sorting to the dependent variable: > > [x, I] = gsort(vv12,"g","i"); > y = vt12(I); > > Then you can proceed to interpolate with spline or lsg_splin. > > Regards, > > Federico Miyara > > > On 10/04/2020 21:05, Daniel Stringari wrote: > > Federico, > > I appreciate the help. Below is a list of the code on which I try to plot > the data with Isq_splin: > > c = size (vt12) > a = 0 > b = c (1) // c (1) = 16 > n = c (1) > x = linspace (a, b, n) > [y, d] = lsq_splin (vt12, vv12, x ') > plot (y, d, 'r') > xlabel ('Speed (rpm)') > ylabel ('Torque (Nm)') > title ('Torque x speed values') > > //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57 3602.73 > 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49 6232.1 > //vv12 = 40.16 39.93 39.71 39.49 69.04 68.54 95.32 119.26 > 140.49 139.32 155.62 154.37 93.27 92.82 92.38 91.94 > > but I'm getting the error: lsq_plin: There are not enough points to adjust. > > Does anyone understand what could be wrong? > > On Wed, Apr 8, 2020 at 12:54 AM Federico Miyara > wrote: > >> >> Daniel, >> >> You may try with lsq_spline, which unlike ordinary spline, doesn't fit >> the data exactly, and it doesn't need the data with any particular order. >> >> But trying to understand your graph, it seems that you should parametrize >> two variables independently, each one with respect to the index. Something >> like this: >> >> x = [x1, x2, ..., xn] >> y = [y1, y2, ..., yn] >> >> Then you approximate x vs 1:n and y vs 1:n using spline or lsq_splin. >> Finally you plot xs vs ys (the smoothed versions of x and y) >> >> Regards, >> >> Federico Miyara >> >> >> On 07/04/2020 22:48, Daniel Stringari wrote: >> >> Good night friends, >> I wrote an email before, but I believe that I was not clear in my words and >> so I will write more clearly. >> >> In this annex 1, I have the graph I am generating. Basically I am extracting >> values of x (speed) and y (torque) from excel and generating vectors of x [] >> and y [] to plot internal lines. I want to smooth these lines, but the >> functions of the scilab are only for growing points. I thought about >> creating cubic splines manually, but I don't know how to do it. Can anybody >> help me ? >> >> In addition, I would like to color my chart with level colors according to >> the colorbar, but I am not able to implement contour2d for this case. >> >> thanks. >> >> >> >> >> -- >> Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html >> _______________________________________________ >> users mailing listusers at lists.scilab.orghttp://lists.scilab.org/mailman/listinfo/users >> >> >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> http://lists.scilab.org/mailman/listinfo/users >> > > _______________________________________________ > users mailing listusers at lists.scilab.orghttp://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: From stephane.mottelet at utc.fr Sun Apr 12 17:00:12 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Sun, 12 Apr 2020 17:00:12 +0200 Subject: [Scilab-users] Efficiency map In-Reply-To: References: Message-ID: <177529ba-81f5-2a05-0b91-ece74816d57b@utc.fr> Hello Daniel, There can be different answers depending on what you are trying to obtain at the end. Do you need to smooth curves by themselves, or are you somewhat trying to build? a smooth surface based on iso-value curves (your TORQUE X SPEED curve ?) ? In this latter case, can you provide the efficiency value associated to each TORQUE X SPEED curve ? In the former case, you need some ordering of your data, e.g. by angle computed with center located at the mass center of points, then least squares splines could be applied more efficiently. S. Le 07/04/2020 ? 00:13, Daniel Stringari a ?crit?: > Dear friends, I'm still a layman at SCILAB, but I'm using SCILAB this > week to be able to plot an efficiency map through a routine I created > on it. Basically the efficiency map is summarized in*?annex 1_0 and? > annex 1_1*(I took it from the internet to exemplify the problem), > where through a TORQUE X SPEED curve I have efficiency lines. > In *annex 2*, I have an example of how my curve looks so far. Based on > the example, I have two problems: > 1) I tried to use the SPLIN function to interpolate the points, but it > doesn't work considering that it works only with strictly increasing > vectors. Any suggestions for me to smooth the curve? > 2) When trying to add colors, I realized that most plotting functions > do not work with values that are not real, which is my case ... All > values with decimal places. Any suggestions for solving this other > problem? > > Friends, I appreciate any form of help... > > attachments: > https://drive.google.com/open?id=1DZORDJfpoezDhzYYyn4oold1O1V1Yz0Z > > > _______________________________________________ > 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 stephane.mottelet at utc.fr Tue Apr 14 10:24:46 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Tue, 14 Apr 2020 10:24:46 +0200 Subject: [Scilab-users] Efficiency map In-Reply-To: <177529ba-81f5-2a05-0b91-ece74816d57b@utc.fr> References: <177529ba-81f5-2a05-0b91-ece74816d57b@utc.fr> Message-ID: Moreover, knowing if you are looking for closed curves (or not) would help. S. Le 12/04/2020 ? 17:00, St?phane Mottelet a ?crit?: > > Hello Daniel, > > There can be different answers depending on what you are trying to > obtain at the end. > > Do you need to smooth curves by themselves, or are you somewhat trying > to build? a smooth surface based on iso-value curves (your TORQUE X > SPEED curve ?) ? > > In this latter case, can you provide the efficiency value associated > to each TORQUE X SPEED curve ? > > In the former case, you need some ordering of your data, e.g. by angle > computed with center located at the mass center of points, then least > squares splines could be applied more efficiently. > > S. > > Le 07/04/2020 ? 00:13, Daniel Stringari a ?crit?: >> Dear friends, I'm still a layman at SCILAB, but I'm using SCILAB this >> week to be able to plot an efficiency map through a routine I created >> on it. Basically the efficiency map is summarized in*?annex 1_0 and? >> annex 1_1*(I took it from the internet to exemplify the problem), >> where through a TORQUE X SPEED curve I have efficiency lines. >> In *annex 2*, I have an example of how my curve looks so far. Based >> on the example, I have two problems: >> 1) I tried to use the SPLIN function to interpolate the points, but >> it doesn't work considering that it works only with strictly >> increasing vectors. Any suggestions for me to smooth the curve? >> 2) When trying to add colors, I realized that most plotting functions >> do not work with values that are not real, which is my case ... All >> values with decimal places. Any suggestions for solving this other >> problem? >> >> Friends, I appreciate any form of help... >> >> attachments: >> https://drive.google.com/open?id=1DZORDJfpoezDhzYYyn4oold1O1V1Yz0Z >> >> >> _______________________________________________ >> 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 > > _______________________________________________ > 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 arvid at softube.com Tue Apr 14 16:51:13 2020 From: arvid at softube.com (=?utf-8?B?QXJ2aWQgUm9zw6lu?=) Date: Tue, 14 Apr 2020 14:51:13 +0000 Subject: [Scilab-users] Compiling Scilab for macOS Message-ID: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> Hi, I still can?t find any Scilab 6.1 builds for macOS (despite the info text here: https://www.scilab.org) , so I?m trying to compile one myself. However, I get a bunch of Java errors during compilation. I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this correct, or should I try using some other version or provider for compiling Scilab on macOS Catalina? Cheers, Arvid -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Tue Apr 14 17:00:01 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Tue, 14 Apr 2020 17:00:01 +0200 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> Message-ID: <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> Hello, Le 14/04/2020 ? 16:51, Arvid Ros?n a ?crit?: > > Hi, > > I still can?t find any Scilab 6.1 builds for macOS (despite the info > text here: https://www.scilab.org) , so I?m trying to compile one myself. > Great, at least we will be two now... > > However, I get a bunch of Java errors during compilation. > Which kind ? > > I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this correct, > Yes. S. > or should I try using some other version or provider for compiling > Scilab on macOS Catalina? > > Cheers, > > Arvid > > > _______________________________________________ > 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 arvid at softube.com Tue Apr 14 17:55:31 2020 From: arvid at softube.com (=?utf-8?B?QXJ2aWQgUm9zw6lu?=) Date: Tue, 14 Apr 2020 15:55:31 +0000 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> Message-ID: Sorry for top-posting, but here are a few of the errors I get: Something missing with: import javax.activation.MimetypesFileTypeMap; A bunch of these: compile: [javac] Compiling 1 source file to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/build/classes [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java [javac] warning: Supported source version 'RELEASE_6' from annotation processor 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor' less than -source '8' [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java:17: error: package javax.annotation does not exist [javac] @javax.annotation.Generated("JFlex") [javac] ^ [javac] 1 error [javac] 1 warning And also this one: compile: [javac] Compiling 5 source files to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/build/classes/v2 [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_Scilab.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_ScilabJNI.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/JavasciException.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Scilab.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/ScilabVariablesJavasci.java [javac] warning: [options] bootstrap class path not set in conjunction with -source 6 [javac] error: Source option 6 is no longer supported. Use 7 or later. [javac] error: Target option 6 is no longer supported. Use 7 or later. Cheers, Arvid From: Scilab Users List on behalf of St?phane Mottelet Reply to: Users mailing list for Scilab Date: Tuesday, 14 April 2020 at 17:00 To: "users at lists.scilab.org" Subject: Re: [Scilab-users] Compiling Scilab for macOS Hello, Le 14/04/2020 ? 16:51, Arvid Ros?n a ?crit : Hi, I still can?t find any Scilab 6.1 builds for macOS (despite the info text here: https://www.scilab.org) , so I?m trying to compile one myself. Great, at least we will be two now... However, I get a bunch of Java errors during compilation. Which kind ? I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this correct, Yes. S. or should I try using some other version or provider for compiling Scilab on macOS Catalina? Cheers, Arvid _______________________________________________ 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 fmiyara at fceia.unr.edu.ar Tue Apr 14 18:33:00 2020 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Tue, 14 Apr 2020 13:33:00 -0300 Subject: [Scilab-users] spline and color plot on the chart In-Reply-To: References: <1586310531232-0.post@n3.nabble.com> <7e4cf5fe-5dc0-82e6-e17a-9bc47b112f18@fceia.unr.edu.ar> <705465a5-e55f-5312-f57a-13fb3e86d86c@fceia.unr.edu.ar> Message-ID: <52f3e8ce-9f7c-94b9-2e96-cfecbde2c5ce@fceia.unr.edu.ar> Daniel, Looking at the graph from your script there are two striking things. First, your data seems to be heavily clustered at certain regions, I mean, several points very close to each other, then a gap without data (which is conveniently interpolated by the plot clause), then another cluster and so on. From a statistical point of view, each cluster counts as a single point. You don't have information of what happens between neighboring clusters. The second striking thing is that you don't seem to be using the spline concept correctly. You are using it to approximate the same points you already have. To make things worse, you are using lsq_splin (a cannon to kill a fly), which is normally used to get a simpler spline by using less breakpoints than the total number of available points. This will normally give a smooth approximation of data, so that the spline will not necessarily pass through any of your points. It is used when the data set is inconsistent due to noise or measurement errors to avoid over representing irrelevant features. If you use it with the same number of breakpoints as the available data, I guess you will have a spline that pass through all the points (this will be the least-square solution since the error will be zero), so it is the same as an ordinary spline interpolation. The correct way to use a spline is to use it to interpolate your data, i.e., to have much more points than the original ones, or to have them more evenly distributed. You are representing your very same data using a spline, so there is no smoothing. The plot function does some interpolation job, but linearly: it connects points with straight segments. You need to calculate more points and more evenly distributed with your spline, but probably you'll be disappointed because the behavior in the large gaps between data clusters may be strangewith some odd oscillations.. If you can, try to generate your data more evenly. Regards, Federico Miyara On 11/04/2020 21:45, Daniel Stringari wrote: > Federico, > > I am extracting the values of the vectors (vv12 and vt12) from a logic > in which it takes data from a spreadsheet that was generated using > specific software. The vectors (vv12 and vt12) represent an efficiency > curve within the torque x speed plane, I have eleven more of these > vectors that vary in size. I believe that I do not have a role in > which one depends on the other directly. I tried to follow your first > reasoning and arrived at a routine that does not report errors but is > not smoothing my curve either, follow the routine: > > clc > clear > vt12 = [5350.3,5380.19,5410.08,5439.96,4149.5,4179.35,3756.57,3602.73,3568.12,3597.85,3681.91,3711.59,6143.24,6172.86,6202.49,6232.1] > vv12 = [40.16,39.93,39.71,39.49,69.04,68.54,95.32,119.26,140.49,139.32,155.62,154.37,93.27,92.82,92.38,91.94] > > c = size (vt12) > a = 1 > b = c(2) > n = c(2) > x = linspace (a, b, n) > > [yvt,dvt] = lsq_splin(x,vt12,linspace (a,b,n)) > [yvv,dvv] = lsq_splin(x,vv12,linspace (a,b,n)) > > ys=interp(linspace (a,b,n),linspace (a,b,n),yvt,dvt) > xs=interp(linspace (a,b,n),linspace (a,b,n),yvv,dvv) > > plot (ys,xs,'r') > xlabel ('Speed (rpm)') > ylabel ('Torque (Nm)') > title ('Torque x speed values') > Any idea how I can proceed with my goal of smoothing the curve to use the color map later? > > On Sat, Apr 11, 2020 at 9:18 PM Federico Miyara > > wrote: > > > Daniel, > > I'm afraid I was a bit confused with your application case. > > I assumed that there was an independent variable such as time or > other which the other two, vt12 and vv12, depend on. If this were > the case, the expected graph could be a curve or rather a > trajectory with some hysteresis. > > But if your data are just measurements in no particular order of > what is a functional relation of one variable respect to the > other, for instance vt12 = f(vv12), then the approach is > different. You should basically sort the independent variable in > increasing order using gsort and apply the same sorting to the > dependent variable: > > [x, I] = gsort(vv12,"g","i"); > y = vt12(I); > > Then you can proceed to interpolate with spline or lsg_splin. > > Regards, > > Federico Miyara > > > On 10/04/2020 21:05, Daniel Stringari wrote: >> Federico, >> >> I appreciate the help. Below is a list of the code on which I try >> to plot the data with Isq_splin: >> >> c = size (vt12) >> a = 0 >> b = c (1) // c (1) = 16 >> n = c (1) >> x = linspace (a, b, n) >> [y, d] = lsq_splin (vt12, vv12, x ') >> plot (y, d, 'r') >> xlabel ('Speed (rpm)') >> ylabel ('Torque (Nm)') >> title ('Torque x speed values') >> >> //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57 >> 3602.73 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49 >> 6232.1 >> //vv12 = 40.16 ? 39.93 ? 39.71 ? 39.49 ? 69.04 ? 68.54 95.32 ? >> 119.26 ? 140.49 ? 139.32 ? 155.62 ? 154.37 93.27 ? 92.82 ? 92.38 >> ? 91.94 >> >> but I'm getting the error: lsq_plin: There are not enough points >> to adjust. >> >> Does anyone understand what could be wrong? >> >> On Wed, Apr 8, 2020 at 12:54 AM Federico Miyara >> > wrote: >> >> >> Daniel, >> >> You may try with lsq_spline, which unlike ordinary spline, >> doesn't fit the data exactly, and it doesn't need the data >> with any particular order. >> >> But trying to understand your graph, it seems that you should >> parametrize two variables independently, each one with >> respect to the index. Something like this: >> >> x = [x1, x2, ..., xn] >> y = [y1, y2, ..., yn] >> >> Then you approximate x vs 1:n and y vs 1:n using spline or >> lsq_splin. Finally you plot xs vs ys (the smoothed versions >> of x and y) >> >> Regards, >> >> Federico Miyara >> >> >> On 07/04/2020 22:48, Daniel Stringari wrote: >>> Good night friends, >>> I wrote an email before, but I believe that I was not clear in my words and >>> so I will write more clearly. >>> >>> In this annex 1, I have the graph I am generating. Basically I am extracting >>> values of x (speed) and y (torque) from excel and generating vectors of x [] >>> and y [] to plot internal lines. I want to smooth these lines, but the >>> functions of the scilab are only for growing points. I thought about >>> creating cubic splines manually, but I don't know how to do it. Can anybody >>> help me ? >>> >>> In addition, I would like to color my chart with level colors according to >>> the colorbar, but I am not able to implement contour2d for this case. >>> >>> thanks. >>> >>> >>> >>> >>> >>> -- >>> Sent from:http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html >>> _______________________________________________ >>> 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 >> >> >> _______________________________________________ >> 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 > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielstringarita at gmail.com Tue Apr 14 23:08:41 2020 From: danielstringarita at gmail.com (Daniel Stringari) Date: Tue, 14 Apr 2020 14:08:41 -0700 (MST) Subject: [Scilab-users] Efficiency map In-Reply-To: References: <177529ba-81f5-2a05-0b91-ece74816d57b@utc.fr> Message-ID: <1586898521198-0.post@n3.nabble.com> The curve I would like to plot is similar to the one attached. There are several efficiency curves within a SPEEDxTORQUE chart. My problem comes down to a spreadsheet generated by external software where I have three columns: SPEED, TORQUE and EFFICIENCY. The data is all broken and so I have to put an efficiency range to get data of just one efficiency. In this case, I created a function that runs through this matrix to collect the SPEEDxTORQUE data for efficiency (interval) and that is why I have several points nearby that could be reduced to just one. These vectors that I sent initially correspond to only one of these curves, if I'm not mistaken it's the 94% efficiency curve. I was observing the function of contour curves and I thought it would be possible to apply, since I will have to paint the graphic in the future. But I don't know how to do that yet. It is worth mentioning that the points vary according to the efficiency range, that is, it is not possible to predict how many SPEEDxTORQUE points I will have. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From danielstringarita at gmail.com Tue Apr 14 23:12:56 2020 From: danielstringarita at gmail.com (Daniel Stringari) Date: Tue, 14 Apr 2020 14:12:56 -0700 (MST) Subject: [Scilab-users] Efficiency map In-Reply-To: <1586898521198-0.post@n3.nabble.com> References: <177529ba-81f5-2a05-0b91-ece74816d57b@utc.fr> <1586898521198-0.post@n3.nabble.com> Message-ID: <1586898776713-0.post@n3.nabble.com> The curve I have so far is summarized in the attachment below. -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From stephane.mottelet at utc.fr Tue Apr 14 23:48:47 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Tue, 14 Apr 2020 23:48:47 +0200 Subject: [Scilab-users] Efficiency map In-Reply-To: <1586898521198-0.post@n3.nabble.com> References: <177529ba-81f5-2a05-0b91-ece74816d57b@utc.fr> <1586898521198-0.post@n3.nabble.com> Message-ID: <8cb35762-a21e-c5d0-011c-85cdcec247a5@utc.fr> Hello, You are taking the problem by the wrong tip. If I understand your problem, you have scattered (x,y,z) data (x=speed, y=torque, z=efficiency) and you want to approximate this data by a smooth surface z=f(x,y) and want to draw level curves of this surface. So, instead of focusing on curves first, you have to focus on the global approximation of the surface,and the level curves will be easy to determinate afterwards. So please provide your data (you can send it to me in a private message) if you want us to test different approaches. S. Le 14/04/2020 ? 23:08, Daniel Stringari a ?crit?: > The curve I would like to plot is similar to the one attached. There are > several efficiency curves within a SPEEDxTORQUE chart. My problem comes down > to a spreadsheet generated by external software where I have three columns: > SPEED, TORQUE and EFFICIENCY. The data is all broken and so I have to put an > efficiency range to get data of just one efficiency. In this case, I created > a function that runs through this matrix to collect the SPEEDxTORQUE data > for efficiency (interval) and that is why I have several points nearby that > could be reduced to just one. These vectors that I sent initially correspond > to only one of these curves, if I'm not mistaken it's the 94% efficiency > curve. I was observing the function of contour curves and I thought it would > be possible to apply, since I will have to paint the graphic in the future. > But I don't know how to do that yet. It is worth mentioning that the points > vary according to the efficiency range, that is, it is not possible to > predict how many SPEEDxTORQUE points I will have. > > > > > > -- > Sent from: https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html > _______________________________________________ > 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 From chinluh.tan at bytecode-asia.com Fri Apr 17 15:38:54 2020 From: chinluh.tan at bytecode-asia.com (Chin Luh Tan) Date: Fri, 17 Apr 2020 21:38:54 +0800 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> Message-ID: <171885d1738.11ad7da53901249.8567276957153740672@bytecode-asia.com> Hi St?phane, Arvid,? Do count me in, 2.5 of us compiling this now, as I am not so familiar with MacOS actually so just count me as 0.5.? I did the compilation using the third parties installed with brew, including the?adoptopenjdk 8 with brew cask install.? I pass the configure without modelica, tk, and build localization, and build process stuck as the same place as Arvid. I tried to apply the code??Change?21438?,??4904f0a9.diff, then the error shown : [javac] symbol: class GL2 [javac] location: class GLShortCuts [javac] /Users/kennethkoh/scilab_master/scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/utils/GLShortCuts.java:94: error: cannot find symbol [javac] public static void useColor(GL2 gl, Color color) { [javac] ^ [javac] symbol: class GL2 [javac] location: class GLShortCuts [javac] /Users/kennethkoh/scilab_master/scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/utils/GLShortCuts.java:106: error: cannot find symbol [javac] public static void setEnable(GL2 gl, int option, boolean status) { [javac] ^ [javac] symbol: class GL2 [javac] location: class GLShortCuts [javac] 84 errors [javac] 2 warnings Any advice? Thanks. Regards, Chin Luh ---- On Tue, 14 Apr 2020 23:55:31 +0800 Arvid Ros?n wrote ---- Sorry for top-posting, but here are a few of the errors I get: ? Something missing with: import javax.activation.MimetypesFileTypeMap; ? A bunch of these: compile: ? ? [javac] Compiling 1 source file to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/build/classes ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java ? ? [javac] warning: Supported source version 'RELEASE_6' from annotation processor 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor' less than -source '8' ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java:17: error: package javax.annotation does not exist ? ? [javac] @javax.annotation.Generated("JFlex") ? ? [javac]? ? ? ? ? ? ? ? ? ^ ? ? [javac] 1 error ? ? [javac] 1 warning ? And also this one: compile: ? ? [javac] Compiling 5 source files to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/build/classes/v2 ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_Scilab.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_ScilabJNI.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/JavasciException.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Scilab.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/ScilabVariablesJavasci.java ? ? [javac] warning: [options] bootstrap class path not set in conjunction with -source 6 ? ? [javac] error: Source option 6 is no longer supported. Use 7 or later. ? ? [javac] error: Target option 6 is no longer supported. Use 7 or later. ? Cheers, Arvid ? From: Scilab Users List on behalf of St?phane Mottelet Reply to: Users mailing list for Scilab Date: Tuesday, 14 April 2020 at 17:00 To: "mailto:users at lists.scilab.org" Subject: Re: [Scilab-users] Compiling Scilab for macOS ? Hello, Le 14/04/2020 ? 16:51, Arvid Ros?n a ?crit?: Hi, ? I still can?t find any Scilab 6.1 builds for macOS (despite the info text here: https://www.scilab.org) , so I?m trying to compile one myself. Great, at least we will be two now... However, I get a bunch of Java errors during compilation. Which kind ? I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this correct, Yes. S. or should I try using some other version or provider for compiling Scilab on macOS Catalina? ? Cheers, Arvid _______________________________________________ users mailing list mailto: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 _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From nomiya at galaxy.dti.ne.jp Fri Apr 17 16:08:03 2020 From: nomiya at galaxy.dti.ne.jp (Masaru Nomiya) Date: Fri, 17 Apr 2020 23:08:03 +0900 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <171885d1738.11ad7da53901249.8567276957153740672@bytecode-asia.com> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> <171885d1738.11ad7da53901249.8567276957153740672@bytecode-asia.com> Message-ID: <87sgh2ciik.wl-nomiya@galaxy.dti.ne.jp> Hello, In the Message; Subject : Re: [Scilab-users] Compiling Scilab for macOS Message-ID : <171885d1738.11ad7da53901249.8567276957153740672 at bytecode-asia.com> Date & Time: Fri, 17 Apr 2020 21:38:54 +0800 [CLT] == Chin Luh Tan has written: [...] CLT> Do count me in, 2.5 of us compiling this now, as I am not so CLT> familiar with CLT> MacOS actually so just count me as 0.5. CLT> I did the compilation using the third parties installed with CLT> brew, including the adoptopenjdk 8 with brew cask install. In case of openSUSE Leap 15.1, I can compile with java 1.9.0 openjdk. With java 1.8.0 openjdk, I've never succesed compiling. HTHs, Regards, --- ????? Masaru Nomiya mail-to: m.nomiya @ gmail.com ???? ???? Think. -- The IBM slogan -- From stephane.mottelet at utc.fr Fri Apr 17 16:43:46 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Fri, 17 Apr 2020 16:43:46 +0200 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> Message-ID: <12f20574-6951-90dd-ebdf-517f4a12cf9a@utc.fr> Hello, I think that you may have more than one JDK installed on your computer. The problem with error: package javax.annotation does not exist is likely due to? java 11. Make sure that at configure time the right JDK is detected, and if necessary force the detection with configure flag --with-jdk=DIR and/or export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'` S. Le 14/04/2020 ? 17:55, Arvid Ros?n a ?crit?: > > Sorry for top-posting, but here are a few of the errors I get: > > Something missing with: > > import javax.activation.MimetypesFileTypeMap; > > A bunch of these: > > compile: > > ? [javac] Compiling 1 source file to > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/build/classes > > ? [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java > > ? [javac] warning: Supported source version 'RELEASE_6' from > annotation processor > 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor' less than > -source '8' > > [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java:17: > error: package javax.annotation does not exist > > ? ? [javac] @javax.annotation.Generated("JFlex") > > ? [javac]? ? ? ? ? ? ? ? ? ^ > > ? [javac] 1 error > > ? [javac] 1 warning > > And also this one: > > compile: > > ? [javac] Compiling 5 source files to > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/build/classes/v2 > > ? [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_Scilab.java > > ? [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_ScilabJNI.java > > ? [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/JavasciException.java > > ? [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Scilab.java > > ? [javac] > /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/ScilabVariablesJavasci.java > > ? [javac] warning: [options] bootstrap class path not set in > conjunction with -source 6 > > ? ? [javac] error: Source option 6 is no longer supported. Use 7 or later. > > ? ? [javac] error: Target option 6 is no longer supported. Use 7 or later. > > Cheers, > > Arvid > > *From: *Scilab Users List on behalf > of St?phane Mottelet > *Reply to: *Users mailing list for Scilab > *Date: *Tuesday, 14 April 2020 at 17:00 > *To: *"users at lists.scilab.org" > *Subject: *Re: [Scilab-users] Compiling Scilab for macOS > > Hello, > > Le 14/04/2020 ? 16:51, Arvid Ros?n a ?crit?: > > Hi, > > I still can?t find any Scilab 6.1 builds for macOS (despite the > info text here: https://www.scilab.org > ) > , so I?m trying to compile one myself. > > Great, at least we will be two now... > > However, I get a bunch of Java errors during compilation. > > Which kind ? > > I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this > correct, > > Yes. > > S. > > or should I try using some other version or provider for compiling > Scilab on macOS Catalina? > > Cheers, > > Arvid > > > > _______________________________________________ > > 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 > > _______________________________________________ > 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 cfuttrup at gmail.com Fri Apr 17 17:14:41 2020 From: cfuttrup at gmail.com (Claus Futtrup) Date: Fri, 17 Apr 2020 17:14:41 +0200 Subject: [Scilab-users] Covid19 model Message-ID: Hi Scilabers A friend (Lars Risbo) published some MATLAB code in LinkedIn for simulating the infection with a company lockdown after some time. I figured I'd try to convert it to Scilab. The code uses ODE45 and I'm not sure that I understand how to convert this MATLAB code to Scilab. I hope you can explain what I need to do to make the code work. Some of the original MATLAB code is found in the comments. // covid19risbo.sce // // SEIRsim1 // Susceptible-Exposed-Infectious-Recovered (SEIR) function dydt=odefun(t, y) if t -------------- next part -------------- A non-text attachment was scrubbed... Name: covid19risbo.jpg Type: image/jpeg Size: 47395 bytes Desc: not available URL: From chinluh.tan at bytecode-asia.com Sat Apr 18 04:43:10 2020 From: chinluh.tan at bytecode-asia.com (Chin Luh Tan) Date: Sat, 18 Apr 2020 10:43:10 +0800 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <12f20574-6951-90dd-ebdf-517f4a12cf9a@utc.fr> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> <12f20574-6951-90dd-ebdf-517f4a12cf9a@utc.fr> Message-ID: <1718b2b1b5f.11f854be1977416.2273769595764789220@bytecode-asia.com> Hi Samuel,? Thanks for your reply. Yes, there are 2 version of Java, another is 13, but in fact, i already use the export JAVA_HOME before "make": Kenneths-MacBook-Air-2:scilab kennethkoh$ java -version openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode) Kenneths-MacBook-Air-2:scilab kennethkoh$ javac -version javac 1.8.0_242 and also the configured show below: checking JAVA_HOME variable... JAVA_HOME variable found, use it as JVM root directory checking for zip or jar files to include on CLASSPATH...? checking to see if the java compiler works... yes Using JAVAC=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javac Java found in /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home checking type of jvm... jdk checking java API version... 1.8 Using the following JNI include flags -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include/darwin Java Configuration: ? JAVA_HOME ........... =? ? JAVAC ............... = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javac ? JAVA_CLASSPATH ...... =? ? JAVA_VERSION ........ = 1.8 ? JAVAC_FLAGS ......... = -g ? JAVA_JNI_INCLUDE .... = -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include/darwin ? JAVA_JNI_LIBS ....... = -framework JavaVM ? JAVA_JNI_LIBS_PRELOAD =? ? JAVA ................ = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java ? JAVADOC ............. = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javadoc ? JAR ................. = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/jar ? ANT ................. = /usr/local/bin/ant but the issue remained the same thanks. Regards, Chin Luh ---- On Fri, 17 Apr 2020 22:43:46 +0800 St?phane Mottelet wrote ---- Hello, I think that you may have more than one JDK installed on your computer. The problem with error: package javax.annotation does not exist is likely due to? java 11. Make sure that at configure time the right JDK is detected, and if necessary force the detection with? configure flag --with-jdk=DIR and/or export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'` S. Le 14/04/2020 ? 17:55, Arvid Ros?n a ?crit?: Sorry for top-posting, but here are a few of the errors I get: ? Something missing with: import javax.activation.MimetypesFileTypeMap; ? A bunch of these: compile: ? ? [javac] Compiling 1 source file to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/build/classes ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java ? ? [javac] warning: Supported source version 'RELEASE_6' from annotation processor 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor' less than -source '8' ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java:17: error: package javax.annotation does not exist ? ? [javac] @javax.annotation.Generated("JFlex") ? ? [javac]? ? ? ? ? ? ? ? ? ^ ? ? [javac] 1 error ? ? [javac] 1 warning ? And also this one: compile: ? ? [javac] Compiling 5 source files to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/build/classes/v2 ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_Scilab.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_ScilabJNI.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/JavasciException.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Scilab.java ? ? [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/ScilabVariablesJavasci.java ? ? [javac] warning: [options] bootstrap class path not set in conjunction with -source 6 ? ? [javac] error: Source option 6 is no longer supported. Use 7 or later. ? ? [javac] error: Target option 6 is no longer supported. Use 7 or later. ? Cheers, Arvid ? From: Scilab Users List mailto:users-bounces at lists.scilab.org on behalf of St?phane Mottelet mailto:stephane.mottelet at utc.fr Reply to: Users mailing list for Scilab mailto:users at lists.scilab.org Date: Tuesday, 14 April 2020 at 17:00 To: mailto:users at lists.scilab.org mailto:users at lists.scilab.org Subject: Re: [Scilab-users] Compiling Scilab for macOS ? Hello, Le 14/04/2020 ? 16:51, Arvid Ros?n a ?crit?: Hi, ? I still can?t find any Scilab 6.1 builds for macOS (despite the info text here: https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.scilab.org) , so I?m trying to compile one myself. Great, at least we will be two now... However, I get a bunch of Java errors during compilation. Which kind ? I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this correct, Yes. S. or should I try using some other version or provider for compiling Scilab on macOS Catalina? ? Cheers, Arvid _______________________________________________ users mailing list mailto:users at lists.scilab.org https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/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 https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.utc.fr/~mottelet _______________________________________________ users mailing list mailto: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 _______________________________________________ users mailing list mailto:users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From chinluh.tan at bytecode-asia.com Sat Apr 18 05:10:31 2020 From: chinluh.tan at bytecode-asia.com (Chin Luh Tan) Date: Sat, 18 Apr 2020 11:10:31 +0800 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <87sgh2ciik.wl-nomiya@galaxy.dti.ne.jp> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> <171885d1738.11ad7da53901249.8567276957153740672@bytecode-asia.com> <87sgh2ciik.wl-nomiya@galaxy.dti.ne.jp> Message-ID: <1718b442755.ee224e5f978094.6261663799752156016@bytecode-asia.com> Dear Nomiya San, Thanks for your input, for ubuntu 18.04 I was able to make it with Openjdk-8, will take note on opensuse leap 15.1 on this issue if i came across this in the future. Great to have experience from all dev/user on the compilation for different distro.?? Thanks again. Regards, Chin Luh ---- On Fri, 17 Apr 2020 22:08:03 +0800 Masaru Nomiya wrote ---- Hello, In the Message; Subject : Re: [Scilab-users] Compiling Scilab for macOS Message-ID : <171885d1738.11ad7da53901249mailto:.8567276957153740672 at bytecode-asia.com> Date & Time: Fri, 17 Apr 2020 21:38:54 +0800 [CLT] == Chin Luh Tan has written: [...] CLT> Do count me in, 2.5 of us compiling this now, as I am not so CLT> familiar with CLT> MacOS actually so just count me as 0.5. CLT> I did the compilation using the third parties installed with CLT> brew, including the adoptopenjdk 8 with brew cask install. In case of openSUSE Leap 15.1, I can compile with java 1.9.0 openjdk. With java 1.8.0 openjdk, I've never succesed compiling. HTHs, Regards, --- ????? Masaru Nomiya mail-to: m.nomiya @ gmail.com ???? ???? Think. ????????????????????-- The IBM slogan -- _______________________________________________ users mailing list mailto:users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From nomiya at galaxy.dti.ne.jp Sat Apr 18 16:12:03 2020 From: nomiya at galaxy.dti.ne.jp (Masaru Nomiya) Date: Sat, 18 Apr 2020 23:12:03 +0900 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <1718b442755.ee224e5f978094.6261663799752156016@bytecode-asia.com> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> <171885d1738.11ad7da53901249.8567276957153740672@bytecode-asia.com> <87sgh2ciik.wl-nomiya@galaxy.dti.ne.jp> <1718b442755.ee224e5f978094.6261663799752156016@bytecode-asia.com> Message-ID: <87zhb8vq6k.wl-nomiya@galaxy.dti.ne.jp> Hello, In the Message; Subject : Re: [Scilab-users] Compiling Scilab for macOS Message-ID : <1718b442755.ee224e5f978094.6261663799752156016 at bytecode-asia.com> Date & Time: Sat, 18 Apr 2020 11:10:31 +0800 [CLT] == Chin Luh Tan has written: CLT> Dear Nomiya San, Oh! How do you know the Japanese manner? Anyway. CLT> Thanks for your input, for ubuntu 18.04 I was able to make it CLT> with Openjdk-8, will take note on opensuse leap 15.1 on this CLT> issue if i came across this in the future. Great to have CLT> experience from all dev/user on the compilation for different CLT> distro. I could compile with java 1.8.0 openjdk, though on openSUSE 42.2. But, the essential difference from openSUSE Leap 15.1 is just jogl2 and gluegen2's version; version 42.2 2.2.4 Leap 15.1 2.3.2 Regards, --- ????? Masaru Nomiya mail-to: m.nomiya @ gmail.com ???? ???? "Bill! You married with Computer. Not with Me!" "No..., with money." From arvid at softube.com Sat Apr 18 16:19:55 2020 From: arvid at softube.com (=?utf-8?B?QXJ2aWQgUm9zw6lu?=) Date: Sat, 18 Apr 2020 14:19:55 +0000 Subject: [Scilab-users] Compiling Scilab for macOS In-Reply-To: <1718b2b1b5f.11f854be1977416.2273769595764789220@bytecode-asia.com> References: <858961DA-6539-4C79-904C-080BC1C6026B@softube.com> <6d25276c-8626-f39f-f165-1929860dded5@utc.fr> <12f20574-6951-90dd-ebdf-517f4a12cf9a@utc.fr> <1718b2b1b5f.11f854be1977416.2273769595764789220@bytecode-asia.com> Message-ID: Hi, Same here. I have various versions (but initially only adoptopenjdk) of java, and I have tried many variants of JAVA_HOME and --with-jdk. It looks like the right version is found, but still no luck. Cheers, Arvid From: Scilab Users List on behalf of Chin Luh Tan Reply to: Users mailing list for Scilab Date: Saturday, 18 April 2020 at 04:44 To: Users mailing list for Scilab Subject: Re: [Scilab-users] Compiling Scilab for macOS Hi Samuel, Thanks for your reply. Yes, there are 2 version of Java, another is 13, but in fact, i already use the export JAVA_HOME before "make": Kenneths-MacBook-Air-2:scilab kennethkoh$ java -version openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode) Kenneths-MacBook-Air-2:scilab kennethkoh$ javac -version javac 1.8.0_242 and also the configured show below: checking JAVA_HOME variable... JAVA_HOME variable found, use it as JVM root directory checking for zip or jar files to include on CLASSPATH... checking to see if the java compiler works... yes Using JAVAC=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javac Java found in /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home checking type of jvm... jdk checking java API version... 1.8 Using the following JNI include flags -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include/darwin Java Configuration: JAVA_HOME ........... = JAVAC ............... = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javac JAVA_CLASSPATH ...... = JAVA_VERSION ........ = 1.8 JAVAC_FLAGS ......... = -g JAVA_JNI_INCLUDE .... = -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/include/darwin JAVA_JNI_LIBS ....... = -framework JavaVM JAVA_JNI_LIBS_PRELOAD = JAVA ................ = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java JAVADOC ............. = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javadoc JAR ................. = /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/jar ANT ................. = /usr/local/bin/ant but the issue remained the same thanks. Regards, Chin Luh ---- On Fri, 17 Apr 2020 22:43:46 +0800 St?phane Mottelet > wrote ---- Hello, I think that you may have more than one JDK installed on your computer. The problem with error: package javax.annotation does not exist is likely due to java 11. Make sure that at configure time the right JDK is detected, and if necessary force the detection with configure flag --with-jdk=DIR and/or export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'` S. Le 14/04/2020 ? 17:55, Arvid Ros?n a ?crit : Sorry for top-posting, but here are a few of the errors I get: Something missing with: import javax.activation.MimetypesFileTypeMap; A bunch of these: compile: [javac] Compiling 1 source file to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/build/classes [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java [javac] warning: Supported source version 'RELEASE_6' from annotation processor 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor' less than -source '8' [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/CSSParser.java:17: error: package javax.annotation does not exist [javac] @javax.annotation.Generated("JFlex") [javac] ^ [javac] 1 error [javac] 1 warning And also this one: compile: [javac] Compiling 5 source files to /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/build/classes/v2 [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_Scilab.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Call_ScilabJNI.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/JavasciException.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/Scilab.java [javac] /Users/arvid/everything/scilab/src/scilab/scilab-6.1.1/scilab/modules/javasci/src/java/org/scilab/modules/javasci/ScilabVariablesJavasci.java [javac] warning: [options] bootstrap class path not set in conjunction with -source 6 [javac] error: Source option 6 is no longer supported. Use 7 or later. [javac] error: Target option 6 is no longer supported. Use 7 or later. Cheers, Arvid From: Scilab Users List on behalf of St?phane Mottelet Reply to: Users mailing list for Scilab Date: Tuesday, 14 April 2020 at 17:00 To: "users at lists.scilab.org" Subject: Re: [Scilab-users] Compiling Scilab for macOS Hello, Le 14/04/2020 ? 16:51, Arvid Ros?n a ?crit : Hi, I still can?t find any Scilab 6.1 builds for macOS (despite the info text here: https://www.scilab.org) , so I?m trying to compile one myself. Great, at least we will be two now... However, I get a bunch of Java errors during compilation. Which kind ? I?m currently using a JDK from AdoptOpenJDK (Java 8). Is this correct, Yes. S. or should I try using some other version or provider for compiling Scilab on macOS Catalina? Cheers, Arvid _______________________________________________ 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 _______________________________________________ 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 _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From perrichon.pierre at wanadoo.fr Mon Apr 20 16:01:02 2020 From: perrichon.pierre at wanadoo.fr (Perrichon) Date: Mon, 20 Apr 2020 16:01:02 +0200 Subject: [Scilab-users] Non defined variable do not create error message within a superblock with HYSTERESIS Message-ID: Hello, When importing superblock from complex diagrams, Errors are not detected if variables are not declared inside a superblock. They are only detected at the top diagram This is a critical bug Best regards Pierre P. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.jpg Type: image/jpeg Size: 5724 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image006.jpg Type: image/jpeg Size: 7407 bytes Desc: not available URL: From perrichon.pierre at wanadoo.fr Mon Apr 20 16:09:32 2020 From: perrichon.pierre at wanadoo.fr (Perrichon) Date: Mon, 20 Apr 2020 16:09:32 +0200 Subject: [Scilab-users] Non defined variable do not create error message within a superblock with HYSTERESIS Message-ID: PS : see bugzilla 16411 De : Perrichon Envoy? : lundi 20 avril 2020 16:01 ? : 'Users mailing list for Scilab' Objet : Non defined variable do not create error message within a superblock with HYSTERESIS Hello, When importing superblock from complex diagrams, Errors are not detected if variables are not declared inside a superblock. They are only detected at the top diagram This is a critical bug Best regards Pierre P. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 5519 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 7369 bytes Desc: not available URL: From stephane.mottelet at utc.fr Tue Apr 21 19:21:30 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Tue, 21 Apr 2020 19:21:30 +0200 Subject: [Scilab-users] Scilab 6.1 for OSX is out ! Message-ID: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> Hi all, Finally I managed to package a branch-6.1 version. "branch-6.1" means that you will have the actual features of 6.1 version plus the bug fixes and improvements provided by the team and contributors since its release. The archive is available to dowload at the following url: https://www.utc.fr/~mottelet/scilab_for_macOS.html Tests have been made under HighSierra, Mojave, Catalina and everything seems OK. Please use the ML to report eventual problems. Enjoy ! -- 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 From heinznabielek at me.com Tue Apr 21 20:43:45 2020 From: heinznabielek at me.com (Heinz Nabielek) Date: Tue, 21 Apr 2020 20:43:45 +0200 Subject: [Scilab-users] Scilab 6.1 for OSX is out ! In-Reply-To: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> References: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> Message-ID: <3A6B6279-B870-4935-8A89-243D45366975@me.com> Thanks very much indeed. Works to perfection under macOS 10.15.4 (19E287). Heinz > On 21.04.2020, at 19:21, St?phane Mottelet wrote: > > Hi all, > > Finally I managed to package a branch-6.1 version. "branch-6.1" means that you will have the actual features of 6.1 version plus the bug fixes and improvements provided by the team and contributors since its release. The archive is available to dowload at the following url: > > https://www.utc.fr/~mottelet/scilab_for_macOS.html > > Tests have been made under HighSierra, Mojave, Catalina and everything seems OK. Please use the ML to report eventual problems. > > Enjoy ! > > -- > 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 > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From chinluh.tan at bytecode-asia.com Wed Apr 22 07:41:36 2020 From: chinluh.tan at bytecode-asia.com (Chin Luh Tan) Date: Wed, 22 Apr 2020 13:41:36 +0800 Subject: [Scilab-users] [Scilab-Dev] Scilab 6.1 for OSX is out ! In-Reply-To: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> References: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> Message-ID: <171a067e718.c333271a93207.2361529335510130482@bytecode-asia.com> Thanks Stephane! I tested to launch on Catalina and HS, no problem in launching, some basics functions testing, plots, and xcos.? Regards, Chin Luh ---- On Wed, 22 Apr 2020 01:21:30 +0800 St?phane Mottelet wrote ---- Hi all, Finally I managed to package a branch-6.1 version. "branch-6.1" means that you will have the actual features of 6.1 version plus the bug fixes and improvements provided by the team and contributors since its release. The archive is available to dowload at the following url: https://www.utc.fr/~mottelet/scilab_for_macOS.html Tests have been made under HighSierra, Mojave, Catalina and everything seems OK. Please use the ML to report eventual problems. Enjoy ! -- 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 _______________________________________________ dev mailing list mailto:dev at lists.scilab.org http://lists.scilab.org/mailman/listinfo/dev -------------- next part -------------- An HTML attachment was scrubbed... URL: From yann.debray at scilab-enterprises.com Wed Apr 22 08:18:33 2020 From: yann.debray at scilab-enterprises.com (Yann Debray @ Scilab) Date: Wed, 22 Apr 2020 06:18:33 +0000 (UTC) Subject: [Scilab-users] [Scilab-Dev] Scilab 6.1 for OSX is out ! In-Reply-To: <171a067e718.c333271a93207.2361529335510130482@bytecode-asia.com> References: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> <171a067e718.c333271a93207.2361529335510130482@bytecode-asia.com> Message-ID: Dear St?phane, Thank you very much.I will report this on our website. --Yann DebrayScilab DirectorESI GroupCell: +33 6 45 81 65 06Website: https://www.scilab.org On Wed, Apr 22, 2020 at 7:42 AM +0200, "Chin Luh Tan" wrote: Thanks Stephane! I tested to launch on Catalina and HS, no problem in launching, some basics functions testing, plots, and xcos.? Regards, Chin Luh ---- On Wed, 22 Apr 2020 01:21:30 +0800 St?phane Mottelet wrote ---- Hi all, Finally I managed to package a branch-6.1 version. "branch-6.1" means that you will have the actual features of 6.1 version plus the bug fixes and improvements provided by the team and contributors since its release. The archive is available to dowload at the following url: https://www.utc.fr/~mottelet/scilab_for_macOS.html Tests have been made under HighSierra, Mojave, Catalina and everything seems OK. Please use the ML to report eventual problems. Enjoy ! -- 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 _______________________________________________ dev mailing list dev at lists.scilab.org http://lists.scilab.org/mailman/listinfo/dev -------------- next part -------------- An HTML attachment was scrubbed... URL: From arvid at softube.com Wed Apr 22 08:40:01 2020 From: arvid at softube.com (=?utf-8?B?QXJ2aWQgUm9zw6lu?=) Date: Wed, 22 Apr 2020 06:40:01 +0000 Subject: [Scilab-users] [Scilab-Dev] Scilab 6.1 for OSX is out ! In-Reply-To: References: <5346a48b-59f6-5676-b52b-00efc63e7a37@utc.fr> <171a067e718.c333271a93207.2361529335510130482@bytecode-asia.com> Message-ID: Indeed, Thank you very much! Basic stuff works here too on Catalina. However, I do have some problems running and compiling my C++-libraries in this version. I get the following linking problem: Symbol not found: __ZN5types5TList8getFieldERKNSt3__112basic_stringIwNS1_11char_traitsIwEENS1_9allocatorIwEEEE Referenced from: ? Either at runtime, or variations on the same theme when compiling, like this: "types::TList::getField(std::__1::basic_string, std::__1::allocator > const&)", referenced from: collectfields_gw(std::__1::vector >&, int, std::__1::vector >&) in Any ideas? Maybe the TList class has changed somehow. I guess I need to go and check in the code, but any pointers here would be appreciated. Cheers, Arvid From: Scilab Users List on behalf of "Yann Debray @ Scilab" Reply to: Users mailing list for Scilab Date: Wednesday, 22 April 2020 at 08:19 To: Users mailing list for Scilab , List dedicated to the development of Scilab Cc: List dedicated to the development of Scilab , Users mailing list for Scilab Subject: Re: [Scilab-users] [Scilab-Dev] Scilab 6.1 for OSX is out ! Dear St?phane, Thank you very much. I will report this on our website. -- Yann Debray Scilab Director ESI Group Cell: +33 6 45 81 65 06 Website: https://www.scilab.org On Wed, Apr 22, 2020 at 7:42 AM +0200, "Chin Luh Tan" > wrote: Thanks Stephane! I tested to launch on Catalina and HS, no problem in launching, some basics functions testing, plots, and xcos. Regards, Chin Luh ---- On Wed, 22 Apr 2020 01:21:30 +0800 St?phane Mottelet wrote ---- Hi all, Finally I managed to package a branch-6.1 version. "branch-6.1" means that you will have the actual features of 6.1 version plus the bug fixes and improvements provided by the team and contributors since its release. The archive is available to dowload at the following url: https://www.utc.fr/~mottelet/scilab_for_macOS.html Tests have been made under HighSierra, Mojave, Catalina and everything seems OK. Please use the ML to report eventual problems. Enjoy ! -- 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 _______________________________________________ dev mailing list dev at lists.scilab.org http://lists.scilab.org/mailman/listinfo/dev -------------- next part -------------- An HTML attachment was scrubbed... URL: From stepan.podhorsky at gmail.com Thu Apr 23 12:59:28 2020 From: stepan.podhorsky at gmail.com (Steve) Date: Thu, 23 Apr 2020 03:59:28 -0700 (MST) Subject: [Scilab-users] Scilab integrator Message-ID: <1587639568055-0.post@n3.nabble.com> Hello, I have been facing a problem how to generate event signals based on value at the integrator block in the Scilab Xcos. For example I need to create event signal in case value at the output of the integrator block is equal to zero. I had an idea to use the RELATIONALOP block for the comparison of the value at the output of the integrator with zero but I don?t know how to convert result of this comparison into the event. Can anybody help? -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html From amonmayr at laas.fr Fri Apr 24 13:22:21 2020 From: amonmayr at laas.fr (Antoine Monmayrant) Date: Fri, 24 Apr 2020 13:22:21 +0200 Subject: [Scilab-users] =?utf-8?q?Scilab_6=2E1_does_not_work_on_the_new_Ub?= =?utf-8?q?untu_LTS?= Message-ID: Hi all, I'm testing the newly released LTS for Ubuntu (20.04) and scilab does not work out of the box. I reported the bug here: https://bugzilla.scilab.org/show_bug.cgi?id=16418 Cheers, Antoine From antoine.monmayrant at laas.fr Mon Apr 27 17:40:36 2020 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Mon, 27 Apr 2020 17:40:36 +0200 Subject: [Scilab-users] parsing TSV (or CSV) file with scilab is a nightmare Message-ID: Hi all, This is both a rant and desperate cry for help. I'm trying to parse some TSV data (tab separated data file) with scilab and I cannot find a way to navigate around the minefield of bugs present in meof/mgetl/mgetstr/csvRead. A bit of context: I need to load into scilab data generated by a closed source software. The data is in the form of many TSV files (that I cannot share in full, just some redacted bits) with a header and a footer. I don't want to hand modify these files or edit them in any way (I need to keep this as portable as possible, so no sed/awk/grep...) OPTION 1: csvRead That's the most intuitive solution, however, because of http://bugzilla.scilab.org/show_bug.cgi?id=16391 and the presence of more than 1 empty line in my header/footer, this crashes Scilab. OPTION 2: hand parsing line by line using mgetl/meof I tried: filename="tsv.txt"; [fd, err] = mopen(filename, 'rt'); while ~meof(fd) do ??? txtline=mgetl(fd,1); end mclose(fd) Saddly, and contrary to what's written in "help mgetl", meof keeps on returning 0, well passed the end of the file and the while never ends! OPTION 3: hand parsing chunk by chunk using mgetstr/meof "help meof" does not confirm that meof should work with mgetl, but mgetstr is specifically listed. I thus tried: filename="tsv.txt"; [fd, err] = mopen(filename, 'rt'); while ~meof(fd) do ??? txtchunk=mgetstr(80,fd); end mclose(fd) But thanks to http://bugzilla.scilab.org/show_bug.cgi?id=16419 this is also crashing Scilab. OPTION 4: Can anyone here help me with this? I am really running out of ideas. Did I miss some -hmm- obvious combination of available file parsing scilab functions to achieve my goal? I have the feeling that it would have been faster for me to just learn a totally new language that does not suck at parsing files than trying to get it to work with scilab.... Antoine (depressed) http://bugzilla.scilab.org/show_bug.cgi?id=16419 -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.cheze at cea.fr Mon Apr 27 18:06:06 2020 From: david.cheze at cea.fr (CHEZE David 227480) Date: Mon, 27 Apr 2020 16:06:06 +0000 Subject: [Scilab-users] parsing TSV (or CSV) file with scilab is a nightmare In-Reply-To: References: Message-ID: Hi Antoine, did you also look at fscanfMat ? It's handy when space or tab separators. regards, David ________________________________ De : users [users-bounces at lists.scilab.org] de la part de Antoine Monmayrant [antoine.monmayrant at laas.fr] Envoy? : lundi 27 avril 2020 17:40 ? : Users mailing list for Scilab Objet : [Scilab-users] parsing TSV (or CSV) file with scilab is a nightmare Hi all, This is both a rant and desperate cry for help. I'm trying to parse some TSV data (tab separated data file) with scilab and I cannot find a way to navigate around the minefield of bugs present in meof/mgetl/mgetstr/csvRead. A bit of context: I need to load into scilab data generated by a closed source software. The data is in the form of many TSV files (that I cannot share in full, just some redacted bits) with a header and a footer. I don't want to hand modify these files or edit them in any way (I need to keep this as portable as possible, so no sed/awk/grep...) OPTION 1: csvRead That's the most intuitive solution, however, because of http://bugzilla.scilab.org/show_bug.cgi?id=16391 and the presence of more than 1 empty line in my header/footer, this crashes Scilab. OPTION 2: hand parsing line by line using mgetl/meof I tried: filename="tsv.txt"; [fd, err] = mopen(filename, 'rt'); while ~meof(fd) do txtline=mgetl(fd,1); end mclose(fd) Saddly, and contrary to what's written in "help mgetl", meof keeps on returning 0, well passed the end of the file and the while never ends! OPTION 3: hand parsing chunk by chunk using mgetstr/meof "help meof" does not confirm that meof should work with mgetl, but mgetstr is specifically listed. I thus tried: filename="tsv.txt"; [fd, err] = mopen(filename, 'rt'); while ~meof(fd) do txtchunk=mgetstr(80,fd); end mclose(fd) But thanks to http://bugzilla.scilab.org/show_bug.cgi?id=16419 this is also crashing Scilab. OPTION 4: Can anyone here help me with this? I am really running out of ideas. Did I miss some -hmm- obvious combination of available file parsing scilab functions to achieve my goal? I have the feeling that it would have been faster for me to just learn a totally new language that does not suck at parsing files than trying to get it to work with scilab.... Antoine (depressed) http://bugzilla.scilab.org/show_bug.cgi?id=16419 -------------- next part -------------- An HTML attachment was scrubbed... URL: From aweeks at hidglobal.com Mon Apr 27 18:58:08 2020 From: aweeks at hidglobal.com (Adrian Weeks) Date: Mon, 27 Apr 2020 16:58:08 +0000 Subject: [Scilab-users] [EXT] parsing TSV (or CSV) file with scilab is a nightmare In-Reply-To: References: Message-ID: Hi Antoine, I often have to read csv files with odd lines that trip functions like csvRead so I often use the method below. It may solve your problem. dataread = mgetl(readfile); // Read everything a = []; b = []; ? for i = 1: size(dataread, 'r') do line = dataread(i); if length(line) ~= 0 then // Ignore blank lines line = tokens(line, [' ', ',', ascii(9)]); // Accept spaces, commas or tabs if and(isnum(line)) then // If the line is all-numeric line = strtod(line); a = [a; line(1)]; b = [b; line(2)]; ? end end end Adrian Weeks Development Engineer, Hardware Engineering EMEA Office: +44 (0)2920 528500 | Desk: +44 (0)2920 528523 | Fax: +44 (0)2920 520178 aweeks at hidglobal.com [HID Global Logo] Unit 3, Cae Gwyrdd, Green meadow Springs, Cardiff, UK, CF15 7AB. www.hidglobal.com From: users On Behalf Of Antoine Monmayrant Sent: 27 April 2020 16:41 To: Users mailing list for Scilab Subject: [EXT] [Scilab-users] parsing TSV (or CSV) file with scilab is a nightmare *** Please use caution this is an externally originating email. *** Hi all, This is both a rant and desperate cry for help. I'm trying to parse some TSV data (tab separated data file) with scilab and I cannot find a way to navigate around the minefield of bugs present in meof/mgetl/mgetstr/csvRead. A bit of context: I need to load into scilab data generated by a closed source software. The data is in the form of many TSV files (that I cannot share in full, just some redacted bits) with a header and a footer. I don't want to hand modify these files or edit them in any way (I need to keep this as portable as possible, so no sed/awk/grep...) OPTION 1: csvRead That's the most intuitive solution, however, because of http://bugzilla.scilab.org/show_bug.cgi?id=16391 and the presence of more than 1 empty line in my header/footer, this crashes Scilab. OPTION 2: hand parsing line by line using mgetl/meof I tried: filename="tsv.txt"; [fd, err] = mopen(filename, 'rt'); while ~meof(fd) do txtline=mgetl(fd,1); end mclose(fd) Saddly, and contrary to what's written in "help mgetl", meof keeps on returning 0, well passed the end of the file and the while never ends! OPTION 3: hand parsing chunk by chunk using mgetstr/meof "help meof" does not confirm that meof should work with mgetl, but mgetstr is specifically listed. I thus tried: filename="tsv.txt"; [fd, err] = mopen(filename, 'rt'); while ~meof(fd) do txtchunk=mgetstr(80,fd); end mclose(fd) But thanks to http://bugzilla.scilab.org/show_bug.cgi?id=16419 this is also crashing Scilab. OPTION 4: Can anyone here help me with this? I am really running out of ideas. Did I miss some -hmm- obvious combination of available file parsing scilab functions to achieve my goal? I have the feeling that it would have been faster for me to just learn a totally new language that does not suck at parsing files than trying to get it to work with scilab.... Antoine (depressed) http://bugzilla.scilab.org/show_bug.cgi?id=16419 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 1751 bytes Desc: image001.gif URL: From j-lan at online.no Mon Apr 27 19:23:02 2020 From: j-lan at online.no (=?UTF-8?Q?Jan_=c3=85ge_Langeland?=) Date: Mon, 27 Apr 2020 19:23:02 +0200 Subject: [Scilab-users] parsing TSV (or CSV) file with scilab is a nightmare In-Reply-To: References: Message-ID: <00ea5896-ad1d-5465-87fd-e8375685e436@online.no> Antoine To find out how long the file is (although not strictly necessary) I normally use: fid = mopen(datafile,'rb'); mseek(0,fid,'end'); lef=mtell(fid) mseek(0,fid); Then you can read in the whole file byte by byte (or split it up if it is big) : data=mgeti(lef,'c',fid); The rest is just looking for the different letters and sort based on that. Jan On 2020-04-27 17:40 PM, Antoine Monmayrant wrote: > > Hi all, > > > This is both a rant and desperate cry for help. > I'm trying to parse some TSV data (tab separated data file) with > scilab and I cannot find a way to navigate around the minefield of > bugs present in meof/mgetl/mgetstr/csvRead. > > A bit of context: I need to load into scilab data generated by a > closed source software. > The data is in the form of many TSV files (that I cannot share in > full, just some redacted bits) with a header and a footer. > I don't want to hand modify these files or edit them in any way (I > need to keep this as portable as possible, so no sed/awk/grep...) > > > OPTION 1: csvRead > > That's the most intuitive solution, however, because of > http://bugzilla.scilab.org/show_bug.cgi?id=16391 and the presence of > more than 1 empty line in my header/footer, this crashes Scilab. > > > OPTION 2: hand parsing line by line using mgetl/meof > > I tried: > > filename="tsv.txt"; > [fd, err] = mopen(filename, 'rt'); > while ~meof(fd) do > ??? txtline=mgetl(fd,1); > end > mclose(fd) > > Saddly, and contrary to what's written in "help mgetl", meof keeps on > returning 0, well passed the end of the file and the while never ends! > > > OPTION 3: hand parsing chunk by chunk using mgetstr/meof > > "help meof" does not confirm that meof should work with mgetl, but > mgetstr is specifically listed. > I thus tried: > > filename="tsv.txt"; > [fd, err] = mopen(filename, 'rt'); > while ~meof(fd) do > ??? txtchunk=mgetstr(80,fd); > end > mclose(fd) > > But thanks to http://bugzilla.scilab.org/show_bug.cgi?id=16419 this is > also crashing Scilab. > > > OPTION 4: Can anyone here help me with this? > > I am really running out of ideas. > Did I miss some -hmm- obvious combination of available file parsing > scilab functions to achieve my goal? > I have the feeling that it would have been faster for me to just learn > a totally new language that does not suck at parsing files than trying > to get it to work with scilab.... > > > Antoine > > (depressed) > > > > http://bugzilla.scilab.org/show_bug.cgi?id=16419 > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.monmayrant at laas.fr Tue Apr 28 00:48:10 2020 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Tue, 28 Apr 2020 00:48:10 +0200 Subject: [Scilab-users] parsing TSV (or CSV) file with scilab is a nightmare In-Reply-To: References: Message-ID: Hello David, Thanks. No I did not have a look at fscanfMat, as I had in mind to also import the header and footer. Samuel and Jan also proposed to simply use "mgetl(fd)" to grab the whole file at once. Their solution seems to work (or at least does not crash scilab on the first file I tested!). Thank you all for your kind help, Antoine On 27/04/2020 18:06, CHEZE David 227480 wrote: > > Hi Antoine, > > did you also look at fscanfMat ? It's handy when? space or tab separators. > > regards, > > David > > ------------------------------------------------------------------------ > *De :* users [users-bounces at lists.scilab.org] de la part de Antoine > Monmayrant [antoine.monmayrant at laas.fr] > *Envoy? :* lundi 27 avril 2020 17:40 > *? :* Users mailing list for Scilab > *Objet :* [Scilab-users] parsing TSV (or CSV) file with scilab is a > nightmare > > Hi all, > > > This is both a rant and desperate cry for help. > I'm trying to parse some TSV data (tab separated data file) with > scilab and I cannot find a way to navigate around the minefield of > bugs present in meof/mgetl/mgetstr/csvRead. > > A bit of context: I need to load into scilab data generated by a > closed source software. > The data is in the form of many TSV files (that I cannot share in > full, just some redacted bits) with a header and a footer. > I don't want to hand modify these files or edit them in any way (I > need to keep this as portable as possible, so no sed/awk/grep...) > > > OPTION 1: csvRead > > That's the most intuitive solution, however, because of > http://bugzilla.scilab.org/show_bug.cgi?id=16391 and the presence of > more than 1 empty line in my header/footer, this crashes Scilab. > > > OPTION 2: hand parsing line by line using mgetl/meof > > I tried: > > filename="tsv.txt"; > [fd, err] = mopen(filename, 'rt'); > while ~meof(fd) do > ??? txtline=mgetl(fd,1); > end > mclose(fd) > > Saddly, and contrary to what's written in "help mgetl", meof keeps on > returning 0, well passed the end of the file and the while never ends! > > > OPTION 3: hand parsing chunk by chunk using mgetstr/meof > > "help meof" does not confirm that meof should work with mgetl, but > mgetstr is specifically listed. > I thus tried: > > filename="tsv.txt"; > [fd, err] = mopen(filename, 'rt'); > while ~meof(fd) do > ??? txtchunk=mgetstr(80,fd); > end > mclose(fd) > > But thanks to http://bugzilla.scilab.org/show_bug.cgi?id=16419 this is > also crashing Scilab. > > > OPTION 4: Can anyone here help me with this? > > I am really running out of ideas. > Did I miss some -hmm- obvious combination of available file parsing > scilab functions to achieve my goal? > I have the feeling that it would have been faster for me to just learn > a totally new language that does not suck at parsing files than trying > to get it to work with scilab.... > > > Antoine > > (depressed) > > > > http://bugzilla.scilab.org/show_bug.cgi?id=16419 > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.monmayrant at laas.fr Tue Apr 28 00:54:25 2020 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Tue, 28 Apr 2020 00:54:25 +0200 Subject: [Scilab-users] [EXT] parsing TSV (or CSV) file with scilab is a nightmare In-Reply-To: References: Message-ID: Hello Adrian, In essence, your extremely useful solution is similar to what Samuel and Jan proposed: grab the whole file once. I must admit I did not even consider it given the length of the files involved and how easily I managed to crash scilab on small files. Thanks, Antoine On 27/04/2020 18:58, Adrian Weeks wrote: > > Hi Antoine, > > I often have to read csv files with odd lines that trip functions like > csvRead so I often use the method below.? It may solve your problem. > > dataread = mgetl(readfile); // Read everything > > a = []; > > b = []; > > ? > > for i = 1: size(dataread, 'r') do > > line = dataread(i); > > if length(line) ~= 0 > then???????????????????????????????????????????????? // Ignore blank lines > > line = tokens(line, [' ', ',', ascii(9)]);??????????? // Accept > spaces, commas or tabs > > if and(isnum(line)) then??????????????????????????????? // If the line > is all-numeric > > line = strtod(line); > > a = [a; line(1)]; > > b = [b; line(2)]; > > ? > > end > > end > > end > > Adrian Weeks > Development Engineer, Hardware Engineering EMEA > Office: +44 (0)2920 528500 | Desk: +44 (0)2920 528523 | Fax: +44 > (0)2920 520178 > aweeks at hidglobal.com > > HID Global Logo > > Unit 3, Cae Gwyrdd, > Green meadow Springs, > Cardiff, UK, > CF15 7AB. > www.hidglobal.com > > *From:*users *On Behalf Of *Antoine > Monmayrant > *Sent:* 27 April 2020 16:41 > *To:* Users mailing list for Scilab > *Subject:* [EXT] [Scilab-users] parsing TSV (or CSV) file with scilab > is a nightmare > > **** Please use caution this is an externally originating email. *** *** > > Hi all, > > This is both a rant and desperate cry for help. > I'm trying to parse some TSV data (tab separated data file) with > scilab and I cannot find a way to navigate around the minefield of > bugs present in meof/mgetl/mgetstr/csvRead. > > A bit of context: I need to load into scilab data generated by a > closed source software. > The data is in the form of many TSV files (that I cannot share in > full, just some redacted bits) with a header and a footer. > I don't want to hand modify these files or edit them in any way (I > need to keep this as portable as possible, so no sed/awk/grep...) > > > OPTION 1: csvRead > > That's the most intuitive solution, however, because of > http://bugzilla.scilab.org/show_bug.cgi?id=16391 > > and the presence of more than 1 empty line in my header/footer, this > crashes Scilab. > > > OPTION 2: hand parsing line by line using mgetl/meof > > I tried: > > filename="tsv.txt"; > [fd, err] = mopen(filename, 'rt'); > while ~meof(fd) do > ??? txtline=mgetl(fd,1); > end > mclose(fd) > > Saddly, and contrary to what's written in "help mgetl", meof keeps on > returning 0, well passed the end of the file and the while never ends! > > > OPTION 3: hand parsing chunk by chunk using mgetstr/meof > > "help meof" does not confirm that meof should work with mgetl, but > mgetstr is specifically listed. > I thus tried: > > filename="tsv.txt"; > [fd, err] = mopen(filename, 'rt'); > while ~meof(fd) do > ??? txtchunk=mgetstr(80,fd); > end > mclose(fd) > > But thanks to http://bugzilla.scilab.org/show_bug.cgi?id=16419 > > this is also crashing Scilab. > > > OPTION 4: Can anyone here help me with this? > > I am really running out of ideas. > Did I miss some -hmm- obvious combination of available file parsing > scilab functions to achieve my goal? > I have the feeling that it would have been faster for me to just learn > a totally new language that does not suck at parsing files than trying > to get it to work with scilab.... > > Antoine > > (depressed) > > http://bugzilla.scilab.org/show_bug.cgi?id=16419 > > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 1751 bytes Desc: not available URL: From jrafaelbguerra at hotmail.com Tue Apr 28 10:14:15 2020 From: jrafaelbguerra at hotmail.com (Rafael Guerra) Date: Tue, 28 Apr 2020 08:14:15 +0000 Subject: [Scilab-users] [EXT] parsing TSV (or CSV) file with scilab is a nightmare In-Reply-To: References: Message-ID: Antoine, One workflow that works fast for me, for large data files, is to load first the whole file with mgetl, then remove all empty lines using isempty in a loop (as shown below), process the header block, isolate the data block and save it to a temporary backup file to disk using mputl, then load very efficiently from disk that backup file using fscanfMat. tlines= mgetl(fid,-1); // reads lines until end of file into 1 column text vector bool= ~cellfun(isempty,tlines); tlines= tlines(bool); // removes empty lines function out_text=cellfun(fun, in_text) // Applies function to input text (column strings vector), line by line n=size(in_text,1); for i=1:n; out_text(i)=fun(in_text(i)); end endfunction Regards, Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From j-lan at online.no Tue Apr 28 11:18:38 2020 From: j-lan at online.no (=?UTF-8?Q?Jan_=c3=85ge_Langeland?=) Date: Tue, 28 Apr 2020 11:18:38 +0200 Subject: [Scilab-users] [EXT] parsing TSV (or CSV) file with scilab In-Reply-To: References: Message-ID: <4273df1c-60d5-ff7b-f63c-68ce658b0835@online.no> I find it safer to process the data without returning to a disk file. As mentioned I actually prefer to start with mgeti() and read the file as binary, as then all byte values are accepted. But anyway with the data separated in lines, it is relatively simple to split up with the wanted separators and decimal sign : clear dataset; headerlines=3: footerlines=2: for k=1:size(in_text,1) if k>headerlines && k > Antoine, > > One workflow that works fast for me, for large data files, is to load > first the whole file with mgetl, then remove all empty lines using > isempty in a loop (as shown below), process the header block, isolate > the data block and save it to a temporary backup file to disk using > mputl, then load very efficiently from disk that backup file using > fscanfMat. > > tlines=mgetl(fid,-1); /// reads lines until end of file into 1 column > text vector/ > > bool=~cellfun(isempty,tlines); > > tlines=tlines(bool); /// removes empty lines/ > > function*out_text*=_cellfun_(*fun*, *in_text*) > > /// Applies function to input text (column strings vector), line by line/ > > n=size(*in_text*,1); > > for i=1:n; > > *out_text*(i)=*fun*(*in_text*(i)); > > end > > endfunction > > Regards, > > Rafael > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.monmayrant at laas.fr Wed Apr 29 14:51:51 2020 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Wed, 29 Apr 2020 14:51:51 +0200 Subject: [Scilab-users] Really headless figure generation in scilab Message-ID: Hello All, Here is a Covid19 & forced remote work issue. One of my students has to run some of his simulations and generate png/svg figures on a linux workstation we don't have physical access to given the current lockdown. The problem is that from his Windows laptop without X server, he cannot "ssh -YC" to the linux workstation but only "ssh -X". He thus only have access to "-nogui" or "-nwni" modes were all the graphics macros are deactivate. Any of you ever faced a similar situation and found a solution? Thanks in advance, Antoine PS: it's a pity that scilab is not able to do real headless figure generation. From stephane.mottelet at utc.fr Wed Apr 29 14:54:56 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 29 Apr 2020 14:54:56 +0200 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: References: Message-ID: <70499557-7d09-024c-f887-3675b731cafb@utc.fr> Hello, Is VNC installed on the remote computer ? Ideally, TurboVNC is the best choice because it includes headless OpenGL drivers. S. Le 29/04/2020 ? 14:51, Antoine Monmayrant a ?crit?: > Hello All, > > Here is a Covid19 & forced remote work issue. > One of my students has to run some of his simulations and generate > png/svg figures on a linux workstation we don't have physical access > to given the current lockdown. > > The problem is that from his Windows laptop without X server, he > cannot "ssh -YC" to the linux workstation but only "ssh -X". > He thus only have access to "-nogui" or "-nwni" modes were all the > graphics macros are deactivate. > > Any of you ever faced a similar situation and found a solution? > > Thanks in advance, > > > Antoine > > PS: it's a pity that scilab is not able to do real headless figure > generation. > > _______________________________________________ > 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 From stephane.mottelet at utc.fr Wed Apr 29 15:18:39 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 29 Apr 2020 15:18:39 +0200 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: References: Message-ID: You should start Scilab this way: SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 _JAVA_OPTIONS='-Djava.awt.headless=true' bin/scilab-adv-cli You will be able to use graphic commands (without visible output) and then export directy with e.g. xs2pdf. S. Le 29/04/2020 ? 14:51, Antoine Monmayrant a ?crit?: > Hello All, > > Here is a Covid19 & forced remote work issue. > One of my students has to run some of his simulations and generate > png/svg figures on a linux workstation we don't have physical access > to given the current lockdown. > > The problem is that from his Windows laptop without X server, he > cannot "ssh -YC" to the linux workstation but only "ssh -X". > He thus only have access to "-nogui" or "-nwni" modes were all the > graphics macros are deactivate. > > Any of you ever faced a similar situation and found a solution? > > Thanks in advance, > > > Antoine > > PS: it's a pity that scilab is not able to do real headless figure > generation. > > _______________________________________________ > 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 From antoine.monmayrant at laas.fr Wed Apr 29 15:28:19 2020 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Wed, 29 Apr 2020 15:28:19 +0200 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: References: Message-ID: <5664ae92-3478-6364-9681-de704e793674@laas.fr> On 29/04/2020 15:18, St?phane Mottelet wrote: > > SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 > _JAVA_OPTIONS='-Djava.awt.headless=true' Thanks St?phane for this dark magic! It works. Is this documented somewhere? Antoine From stephane.mottelet at utc.fr Wed Apr 29 15:32:53 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 29 Apr 2020 15:32:53 +0200 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: <5664ae92-3478-6364-9681-de704e793674@laas.fr> References: <5664ae92-3478-6364-9681-de704e793674@laas.fr> Message-ID: I don't think so. This is the way Scilab is launched to build the documentation. S. Le 29/04/2020 ? 15:28, Antoine Monmayrant a ?crit?: > > On 29/04/2020 15:18, St?phane Mottelet wrote: >> >> SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 >> _JAVA_OPTIONS='-Djava.awt.headless=true' > > > Thanks St?phane for this dark magic! > It works. > Is this documented somewhere? > > > Antoine > > _______________________________________________ > 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 From Clement.David at esi-group.com Thu Apr 30 09:22:39 2020 From: Clement.David at esi-group.com (=?utf-8?B?Q2zDqW1lbnQgRGF2aWQ=?=) Date: Thu, 30 Apr 2020 07:22:39 +0000 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: References: <5664ae92-3478-6364-9681-de704e793674@laas.fr> Message-ID: Hello, Thanks for sharing the info St?phane, it is documented on the scilab binary help page, on https://help.scilab.org/docs/6.1.0/en_US/scilab.html . However, this might not be clear enough. Maybe adding your usage as an example can help? Thanks, -- Cl?ment > -----Original Message----- > From: users On Behalf Of St?phane Mottelet > Sent: Wednesday, April 29, 2020 3:33 PM > To: users at lists.scilab.org > Subject: Re: [Scilab-users] Really headless figure generation in scilab > > I don't think so. This is the way Scilab is launched to build the documentation. > > S. > > Le 29/04/2020 ? 15:28, Antoine Monmayrant a ?crit?: > > > > On 29/04/2020 15:18, St?phane Mottelet wrote: > >> > >> SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 > >> _JAVA_OPTIONS='-Djava.awt.headless=true' > > > > > > Thanks St?phane for this dark magic! > > It works. > > Is this documented somewhere? > > > > > > Antoine > > > > _______________________________________________ > > 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 > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From stephane.mottelet at utc.fr Thu Apr 30 09:26:51 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 30 Apr 2020 09:26:51 +0200 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: References: <5664ae92-3478-6364-9681-de704e793674@laas.fr> Message-ID: Hi, Le 30/04/2020 ? 09:22, Cl?ment David a ?crit?: > Hello, > > Thanks for sharing the info St?phane, it is documented on the scilab binary help page, on https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/help.scilab.org/docs/6.1.0/en_US/scilab.html . However, this might not be clear enough. Yes. Particularly, I don't see any mention of _JAVA_OPTIONS='-Djava.awt.headless=true' which is mandatory (and should be added on-the-fly by the Scilab script), I mean SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 are not enough. S. > Maybe adding your usage as an example can help? > > Thanks, > > -- > Cl?ment > >> -----Original Message----- >> From: users On Behalf Of St?phane Mottelet >> Sent: Wednesday, April 29, 2020 3:33 PM >> To: users at lists.scilab.org >> Subject: Re: [Scilab-users] Really headless figure generation in scilab >> >> I don't think so. This is the way Scilab is launched to build the documentation. >> >> S. >> >> Le 29/04/2020 ? 15:28, Antoine Monmayrant a ?crit?: >>> On 29/04/2020 15:18, St?phane Mottelet wrote: >>>> SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 >>>> _JAVA_OPTIONS='-Djava.awt.headless=true' >>> >>> Thanks St?phane for this dark magic! >>> It works. >>> Is this documented somewhere? >>> >>> >>> Antoine >>> >>> _______________________________________________ >>> users mailing list >>> users at lists.scilab.org >>> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/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 >> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.utc.fr/~mottelet >> >> _______________________________________________ >> 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 -- 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 From antoine.monmayrant at laas.fr Thu Apr 30 11:35:15 2020 From: antoine.monmayrant at laas.fr (Antoine Monmayrant) Date: Thu, 30 Apr 2020 11:35:15 +0200 Subject: [Scilab-users] Really headless figure generation in scilab In-Reply-To: References: Message-ID: Hello St?phane, Sadly, after some testings, it doe not seem to work for me on the machine I connect to with ssh (see transcript below). The connection is done with bare 'ssh' and not 'ssh -X' (contrary to what I wrote in a previous email) and your combination of env variables still results in a bunch of errors... Cheers, Antoine ////////////////////////// ssh remotemachine SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 _JAVA_OPTIONS='-Djava.awt.headless=true' scilab-adv-cli Error: unable to open display Picked up _JAVA_OPTIONS: -Djava.class.path=/usr/share/java/flexdock.jar:/usr/share/java/skinlf.jar:/usr/share/java/looks.jar:/usr/share/java/commons-logging.jar:/usr/share/java/jhall.jar:/usr/share/java/lucene-core-4.10.4.jar:/usr/share/java/lucene-analyzers-common-4.10.4.jar:/usr/share/java/lucene-queryparser-4.10.4.jar:/usr/share/maven-repo/org/freehep/freehep-util/debian/freehep-util-debian.jar:/usr/share/maven-repo/org/freehep/freehep-io/debian/freehep-io-debian.jar:/usr/share/maven-repo/org/freehep/freehep-graphicsio/debian/freehep-graphicsio-debian.jar:/usr/share/java/freehep-graphicsio-emf-2.1.jar:/usr/share/java/freehep-graphics2d-2.1.1.jar:/usr/share/java/jrosetta-API.jar:/usr/share/java/jrosetta-engine-1.0.4.jar:/usr/share/java/jgraphx.jar:/usr/share/java/jogl2.jar:/usr/share/java/gluegen2-rt.jar:/usr/share/java/jeuclid-core.jar:/usr/share/java/jlatexmath-fop-1.0.7.jar:/usr/share/java/fop.jar:/usr/share/java/saxon.jar:/usr/share/java/batik.jar:/usr/share/java/xml-apis-ext.jar:/usr/share/java/commons-io.jar:/usr/share/java/xmlgraphics-commons.jar:/usr/share/java/avalon-framework.jar:/usr/share/java/jlatexmath-1.0.7.jar:/usr/share/java/ecj.jar:/usr/share/java/javax.activation.jar:/usr/share/java/jaxb-runtime.jar:/usr/share/scilab/modules/graphic_objects/jar/org.scilab.modules.graphic_objects.jar:/usr/share/scilab/modules/javasci/jar/org.scilab.modules.javasci.jar:/usr/share/scilab/modules/completion/jar/org.scilab.modules.completion.jar:/usr/share/scilab/modules/preferences/jar/org.scilab.modules.preferences.jar:/usr/share/scilab/modules/scirenderer/jar/scirenderer.jar:/usr/share/scilab/modules/graph/jar/org.scilab.modules.graph.jar:/usr/share/scilab/modules/renderer/jar/org.scilab.modules.renderer.jar:/usr/share/scilab/modules/ui_data/jar/org.scilab.modules.ui_data.jar:/usr/share/scilab/modules/localization/jar/org.scilab.modules.localization.jar:/usr/share/scilab/modules/scinotes/jar/org.scilab.modules.scinotes.jar:/usr/share/scilab/modules/types/jar/org.scilab.modules.types.jar:/usr/share/scilab/modules/history_browser/jar/org.scilab.modules.history_browser.jar:/usr/share/scilab/modules/commons/jar/org.scilab.modules.commons.jar:/usr/share/scilab/modules/console/jar/org.scilab.modules.console.jar:/usr/share/scilab/modules/action_binding/jar/org.scilab.modules.action_binding.jar:/usr/share/scilab/modules/history_manager/jar/org.scilab.modules.history_manager.jar:/usr/share/scilab/modules/core/jar/org.scilab.modules.core.jar:/usr/share/scilab/modules/external_objects_java/jar/org.scilab.modules.external_objects_java.jar:/usr/share/scilab/modules/xcos/jar/org.scilab.modules.xcos.jar:/usr/share/scilab/modules/graphic_export/jar/org.scilab.modules.graphic_export.jar:/usr/share/scilab/modules/jvm/jar/org.scilab.modules.jvm.jar:/usr/share/scilab/modules/gui/jar/org.scilab.modules.gui.jar:/usr/share/scilab/modules/helptools/jar/scilab_ru_RU_help.jar:/usr/share/scilab/modules/helptools/jar/scilab_images.jar:/usr/share/scilab/modules/helptools/jar/org.scilab.modules.helptools.jar:/usr/share/scilab/modules/helptools/jar/scilab_en_US_help.jar: -Djava.awt.headless=true WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.scilab.modules.jvm.LibraryPath (file:/usr/share/scilab/modules/jvm/jar/org.scilab.modules.jvm.jar) to field java.lang.ClassLoader.sys_paths WARNING: Please consider reporting this to the maintainers of org.scilab.modules.jvm.LibraryPath WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Could not access to the Main Scilab Class: Exception in thread "main" java.lang.ExceptionInInitializerError ??????? at org.scilab.modules.localization.Messages.gettext(Unknown Source) ??????? at org.scilab.modules.commons.xml.XConfiguration.(Unknown Source) ??????? at org.scilab.modules.core.Scilab.(Unknown Source) Caused by: java.lang.NullPointerException ??????? at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2646) ??????? at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830) ??????? at java.base/java.lang.System.loadLibrary(System.java:1870) ??????? at org.scilab.modules.localization.MessagesJNI.(Unknown Source) ??????? ... 3 more Scilab cannot create Scilab Java Main-Class (we have not been able to find the main Scilab class. Check if the Scilab and thirdparty packages are available). On 29/04/2020 15:18, St?phane Mottelet wrote: > You should start Scilab this way: > > SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 > _JAVA_OPTIONS='-Djava.awt.headless=true' bin/scilab-adv-cli > > You will be able to use graphic commands (without visible output) and > then export directy with e.g. xs2pdf. > > S. > > Le 29/04/2020 ? 14:51, Antoine Monmayrant a ?crit?: >> Hello All, >> >> Here is a Covid19 & forced remote work issue. >> One of my students has to run some of his simulations and generate >> png/svg figures on a linux workstation we don't have physical access >> to given the current lockdown. >> >> The problem is that from his Windows laptop without X server, he >> cannot "ssh -YC" to the linux workstation but only "ssh -X". >> He thus only have access to "-nogui" or "-nwni" modes were all the >> graphics macros are deactivate. >> >> Any of you ever faced a similar situation and found a solution? >> >> Thanks in advance, >> >> >> Antoine >> >> PS: it's a pity that scilab is not able to do real headless figure >> generation. >> >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users >> > From cfuttrup at gmail.com Thu Apr 30 16:40:23 2020 From: cfuttrup at gmail.com (Claus Futtrup) Date: Thu, 30 Apr 2020 16:40:23 +0200 Subject: [Scilab-users] Covid19 model Message-ID: <8a5ed43a-39a2-342c-de18-afa310eff192@gmail.com> Hi Scilabers On 17. April I sent an email, but I think it wasn't released to the mailing list, I only find it online here: http://mailinglists.scilab.org/Scilab-users-Covid19-model-td4040626.html Here's the email again (without attachment, see above link if you'd like to view the attachment) A friend (Lars Risbo) published some MATLAB code in LinkedIn for simulating the infection with a company lockdown after some time. I figured I'd try to convert it to Scilab. The code usesODE45and I'm not sure that I understand how to convert this MATLAB code to Scilab. I hope you can explain what I need to do to make the code work. Some of the original MATLAB code is found in the comments. // covid19risbo.sce//// SEIRsim1// Susceptible-Exposed-Infectious-Recovered (SEIR)functiondydt=odefun(t, y)ift From stephane.mottelet at utc.fr Thu Apr 30 16:51:23 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 30 Apr 2020 16:51:23 +0200 Subject: [Scilab-users] Covid19 model In-Reply-To: <8a5ed43a-39a2-342c-de18-afa310eff192@gmail.com> References: <8a5ed43a-39a2-342c-de18-afa310eff192@gmail.com> Message-ID: Hi Clauss, Just modify the following lines : t1 = 0:0.1:60; y1 = ode(y0, 0, t1, odefun); // [t1,y1] = ode45(@odefun,[0 60],y0); // run 1st scernario idx=[3:6]; scf(); a = gca(); plot(Begin+t1,y1(idx,:),'-'); // semilogy(Begin+t1,y1(:,idx),'-','LineWidth',3) And you will be fine. ode() needs a vector of time values and the output is oriented transposed w.r.t Matlab output. S. Le 30/04/2020 ? 16:40, Claus Futtrup a ?crit?: > functiondydt=odefun(t, y)ift rate after > lockdownendA=[00-delta*R*y(1)/Npop000;...0-gamdelta*R*y(1)/Npop000;...0gam-delta000;...00delta*(1-Fhosp)000;...00delta*Fhosp0-1/Thosp0;...00delta*R*y(1)/Npop000];dydt=A*y;endBegin=datenum(2020,02,20,0,0,0);// > begin dateDlock=datenum(2020,03,12,0,0,0);// date of > lockdowndays=Dlock-Begin;R0=2.6;// inital R valuegam=1/3;// gamma, the > inverse of average latent timedelta=1/5;// inv time constant which > infectious people either recover or enter hospitalFhosp=0.16;// > fraction of recovering people going to hospitalThosp=14;// average > time of hospitalisationNpop=6e6;// total initial population of > sensitivey0=[Npop;50;50;0;0;0];// [S E I R Hosp ] intial > cond.t1=0:60;y1=ode(y0,0,60,odefun);// [t1,y1] = ode45(@odefun,[0 > 60],y0); // run 1st > scernarioidx=[3:6];scf();a=gca();plot(Begin+t1,y1(:,idx),'-');// > semilogy(Begin+t1,y1(:,idx),'-','LineWidth',3)a.log_flags="nln";xlabel('Date')ylabel('Number > of cases')xgrid();// ax=gca;// ax.YLim=[10 > max(max(y2(:,idx)))];xtitle({'Danish Corona lock down on 20.03.12, vs > 14 days later','R goes from 2.6 to 0.6 at > lockdown'});legend('Infected','Recovered','Hospitalised','Total Cases'); -- 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 chinluh.tan at bytecode-asia.com Thu Apr 30 18:44:57 2020 From: chinluh.tan at bytecode-asia.com (Chin Luh Tan) Date: Fri, 01 May 2020 00:44:57 +0800 Subject: [Scilab-users] Fwd: Re: Corona modelling In-Reply-To: <171c6ae0832.cf74548679481.1373004697343489558@bytecode-asia.com> References: <61797769-8CEB-4391-8C95-A5C56438B43B@me.com> <171c6ae0832.cf74548679481.1373004697343489558@bytecode-asia.com> Message-ID: <171cbfa1738.dd223406246274.6201721570385894168@bytecode-asia.com> Just notice that this email was stuck due to the image attached was too large, and notice the new post by?Claus with the SEIR model from Matlab, perhaps Scilabers could make the model more realistic together. CL ============ Forwarded message ============ From: Chin Luh Tan To: "Users mailing list for Scilab" Date: Thu, 30 Apr 2020 00:03:46 +0800 Subject: Re: [Scilab-users] Corona modelling ============ Forwarded message ============ Hi,? I just modified Stephane's nice GUI to make it able to load the real world data from internet so that we could overlapped the data to the SIR model to study the effect of locked-down, and the meaning of the coefficients.? >From some reading from the internet, the "Susceptible" population is kind of like difficult to determined, and some suggested to use "current cases" as "optimum model" assuming the condition is recovering. As or the "optional model", the "total population" is being used. While?"beta" is the transmission coefficient, "gamma" the recovery factor, can anyone explained more details, perhaps in layman term, how to relate these? parameters to one country condition, such as the relationship between gamma with the number of days (what days is it referring to), beta "actual meaning" in layman term, and perhaps link with some "technical term" the newspaper always seen on papers?? I attached the GUI, which will load 3 sets of data from?Johns Hopkins Github, (https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series) which could be download using following 3 lines directly from the Scilab: --> fn = getURL('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv') --> fn = getURL('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv') --> fn = getURL('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv') and run the GUI as attached. rgds, CL ---- On Mon, 30 Mar 2020 14:13:40 +0800 St?phane Mottelet wrote ---- Hello Heinz, Here is an interactive version (made for my children last week...) : // Confinement COVID-19 ! // Stephane MOTTELET, UTC // Tue Mar 24 08:55:03 CET 2020 // function dydt=sir(t, y, bet, gam, N) dydt=[-bet/N*y(1)*y(2) bet/N*y(1)*y(2)-gam*y(2) gam*y(2)]; endfunction function draw(bet, gam) t=0:1:360; N=6e7; if exists("gcbo") && is_handle_valid(gcbo) sb = gcbo; if sb.tag=="beta" bet=sb.value; gam=findobj("gamma").value else gam=sb.value; bet=findobj("beta").value end y=ode('stiff',[N-1;1;0],0,t,list(sir,bet,gam,N)); curves = findobj("curves"); curves.children(1).data(:,2)=y(3,:); curves.children(2).data(:,2)=y(2,:); curves.children(3).data(:,2)=y(1,:); else y=ode('stiff',[N-1;1;0],0,t,list(sir,bet,gam,N)); scf(0) clf plot(t,y) gce().tag="curves"; gce().children.thickness=2; legend("Susceptible","Infected","Recovered",-1) sb1 = uicontrol("style","slider",... "units","normalized",... "Position", [0.85,0.2,0.05,0.48],... "BackgroundColor", [1,1,1],... "Callback_Type",12,... "sliderstep",[1/1000,1/10],... "min",0.15,"max",0.3,"value",bet,... "Callback","draw","tag","beta"); uicontrol("style","text",... "string","$\beta$",... "units","normalized",... "Position", [0.85,0.125,0.05,0.08],... "BackgroundColor", [1,1,1],... "HorizontalAlignment","center"); sb1 = uicontrol("style","slider",... "units","normalized",... "Position", [0.90,0.2,0.05,0.48],... "BackgroundColor", [1,1,1],... "Callback_Type",12,... "sliderstep",[1/1000,1/10],... "min",0,"max",1/15,"value",gam,... "Callback","draw","tag","gamma"); uicontrol("style","text",... "string","$\gamma$",... "units","normalized",... "Position", [0.9,0.125,0.05,0.08],... "BackgroundColor", [1,1,1],... "HorizontalAlignment","center"); end end clf draw(0.3,1/15) Le 30/03/2020 ? 02:14, Heinz Nabielek a ?crit?: Colleagues: is there an straightforward Scilab approach for solving the three coupled nonlinear differential equations of first order given by the Standard Model of Epidemics? S= number Susceptible: S'=-aSI I= number Infected: I'=aSI - bI R= number Recovered: R'=bI whereby 'a' is the transmission coefficient, 'b' the recovery factor (after Reed-Frost 1928). Initial values for S, I, R are available. Thank you Heinz _______________________________________________ users mailing list mailto: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 _______________________________________________ users mailing list mailto:users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: CoronaSimv2.sce Type: application/octet-stream Size: 5950 bytes Desc: not available URL: From stephane.mottelet at utc.fr Thu Apr 30 19:12:12 2020 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 30 Apr 2020 19:12:12 +0200 Subject: [Scilab-users] Fwd: Re: Corona modelling In-Reply-To: <171cbfa1738.dd223406246274.6201721570385894168@bytecode-asia.com> References: <61797769-8CEB-4391-8C95-A5C56438B43B@me.com> <171c6ae0832.cf74548679481.1373004697343489558@bytecode-asia.com> <171cbfa1738.dd223406246274.6201721570385894168@bytecode-asia.com> Message-ID: <9fa01616-8119-0223-c6b6-ae3c933c0bb0@utc.fr> Hi, My experience with the SIR model (not SEIR) is that the estimated parameters are very sensitive to the initial condition of the Infected pool. Hence, this initial condition should be also considered as a parameter to be identified. However, the main problem (at least with France data) is that fitting Infected and Recovered (cured or dead people) together gives not satisfactory results. My two cents... S. Le 30/04/2020 ? 18:44, Chin Luh Tan a ?crit?: > Just notice that this email was stuck due to the image attached was > too large, and notice the new post by Claus with the SEIR model from > Matlab, perhaps Scilabers could make the model more realistic together. > > CL > > ============ Forwarded message ============ > From: Chin Luh Tan > > To: "Users mailing list for Scilab" > > Date: Thu, 30 Apr 2020 00:03:46 +0800 > Subject: Re: [Scilab-users] Corona modelling > ============ Forwarded message ============ > > Hi, > > I just modified Stephane's nice GUI to make it able to load the > real world data from internet so that we could overlapped the data > to the SIR model to study the effect of locked-down, and the > meaning of the coefficients. > > From some reading from the internet, the "Susceptible" population > is kind of like difficult to determined, and some suggested to use > "current cases" as "optimum model" assuming the condition is > recovering. As or the "optional model", the "total population" is > being used. > > While?"beta" is the transmission coefficient, "gamma" the recovery > factor, can anyone explained more details, perhaps in layman term, > how to relate these? parameters to one country condition, such as > the relationship between gamma with the number of days (what days > is it referring to), beta "actual meaning" in layman term, and > perhaps link with some "technical term" the newspaper always seen > on papers? > > I attached the GUI, which will load 3 sets of data from?Johns > Hopkins Github, > (https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series > ) > which could be download using following 3 lines directly from the > Scilab: > > > --> fn = > getURL('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv > ') > --> fn = > getURL('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv > ') > --> fn = > getURL('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv > ') > > and run the GUI as attached. > > > > > rgds, > CL > > > ---- On Mon, 30 Mar 2020 14:13:40 +0800 *St?phane Mottelet > >* > wrote ---- > > > > > Hello Heinz, > > Here is an interactive version (made for my children last > week...) : > > /// Confinement COVID-19 !/ > /// Stephane MOTTELET, UTC/ > /// Tue Mar 24 08:55:03 CET 2020/ > /// / > function *dydt*=_sir_(*t*, *y*, *bet*, *gam*, *N*) > *dydt*=[-*bet*/*N***y*(1)**y*(2) > *bet*/*N***y*(1)**y*(2)-*gam***y*(2) > *gam***y*(2)]; > endfunction > > function _draw_(*bet*, *gam*) > t=0:1:360; > N=6e7; > if exists("gcbo") && is_handle_valid(gcbo) > sb = gcbo; > if sb.tag=="beta" > *bet*=sb.value; > *gam*=findobj("gamma").value > else > *gam*=sb.value; > *bet*=findobj("beta").value > end > y=ode('stiff',[N-1;1;0],0,t,list(_sir_,*bet*,*gam*,N)); > curves = findobj("curves"); > curves.children(1).data(:,2)=y(3,:); > curves.children(2).data(:,2)=y(2,:); > curves.children(3).data(:,2)=y(1,:); > else > y=ode('stiff',[N-1;1;0],0,t,list(_sir_,*bet*,*gam*,N)); > scf(0) > clf > plot(t,y) > gce().tag="curves"; > gce().children.thickness=2; > legend("Susceptible","Infected","Recovered",-1) > > sb1 = uicontrol("style","slider",... > "units","normalized",... > "Position", [0.85,0.2,0.05,0.48],... > "BackgroundColor", [1,1,1],... > "Callback_Type",12,... > "sliderstep",[1/1000,1/10],... > "min",0.15,"max",0.3,"value",*bet*,... > "Callback","draw","tag","beta"); > > uicontrol("style","text",... > "string","$\beta$",... > "units","normalized",... > "Position", [0.85,0.125,0.05,0.08],... > "BackgroundColor", [1,1,1],... > "HorizontalAlignment","center"); > > sb1 = uicontrol("style","slider",... > "units","normalized",... > "Position", [0.90,0.2,0.05,0.48],... > "BackgroundColor", [1,1,1],... > "Callback_Type",12,... > "sliderstep",[1/1000,1/10],... > "min",0,"max",1/15,"value",*gam*,... > "Callback","draw","tag","gamma"); > > uicontrol("style","text",... > "string","$\gamma$",... > "units","normalized",... > "Position", [0.9,0.125,0.05,0.08],... > "BackgroundColor", [1,1,1],... > "HorizontalAlignment","center"); > > end > end > > clf > > _draw_(0.3,1/15) > > Le 30/03/2020 ? 02:14, Heinz Nabielek a ?crit?: > > Colleagues: > > is there an straightforward Scilab approach for solving the three coupled nonlinear differential equations of first order given by the Standard Model of Epidemics? > > > S= number Susceptible: S'=-aSI > I= number Infected: I'=aSI - bI > R= number Recovered: R'=bI > whereby 'a' is the transmission coefficient, 'b' the recovery factor (after Reed-Frost 1928). > Initial values for S, I, R are available. > > Thank you > Heinz > _______________________________________________ > 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 > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://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 -- 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 cfuttrup at gmail.com Thu Apr 30 20:11:06 2020 From: cfuttrup at gmail.com (Claus Futtrup) Date: Thu, 30 Apr 2020 20:11:06 +0200 Subject: [Scilab-users] Covid19 model In-Reply-To: References: <8a5ed43a-39a2-342c-de18-afa310eff192@gmail.com> Message-ID: Hi St?phane Thank you for showing me how to work ODE. P.S. about Corona modeling, the model by Risbo is nice in that you can implement a lockdown of some sort. It's a simple one-step lockdown, where you have to tune the R-value ... in reality each geographic area is different, related to how much of a lockdown is executed, how dense the population is, etc. Cheers, Claus On 4/30/2020 4:51 PM, St?phane Mottelet wrote: > > Hi Clauss, > > Just modify the following lines : > > t1 = 0:0.1:60; > y1 = ode(y0, 0, t1, odefun); // [t1,y1] = ode45(@odefun,[0 60],y0); // run 1st scernario > idx=[3:6]; > scf(); > a = gca(); > plot(Begin+t1,y1(idx,:),'-'); // semilogy(Begin+t1,y1(:,idx),'-','LineWidth',3) And you will be fine. ode() needs a vector of time values and the output is oriented transposed w.r.t Matlab output. > > S. > > Le 30/04/2020 ? 16:40, Claus Futtrup a ?crit?: >> functiondydt=odefun(t, y)ift> reproductive rate after >> lockdownendA=[00-delta*R*y(1)/Npop000;...0-gamdelta*R*y(1)/Npop000;...0gam-delta000;...00delta*(1-Fhosp)000;...00delta*Fhosp0-1/Thosp0;...00delta*R*y(1)/Npop000];dydt=A*y;endBegin=datenum(2020,02,20,0,0,0);// >> begin dateDlock=datenum(2020,03,12,0,0,0);// date of >> lockdowndays=Dlock-Begin;R0=2.6;// inital R valuegam=1/3;// gamma, >> the inverse of average latent timedelta=1/5;// inv time constant >> which infectious people either recover or enter hospitalFhosp=0.16;// >> fraction of recovering people going to hospitalThosp=14;// average >> time of hospitalisationNpop=6e6;// total initial population of >> sensitivey0=[Npop;50;50;0;0;0];// [S E I R Hosp ] intial >> cond.t1=0:60;y1=ode(y0,0,60,odefun);// [t1,y1] = ode45(@odefun,[0 >> 60],y0); // run 1st >> scernarioidx=[3:6];scf();a=gca();plot(Begin+t1,y1(:,idx),'-');// >> semilogy(Begin+t1,y1(:,idx),'-','LineWidth',3)a.log_flags="nln";xlabel('Date')ylabel('Number >> of cases')xgrid();// ax=gca;// ax.YLim=[10 >> max(max(y2(:,idx)))];xtitle({'Danish Corona lock down on 20.03.12, vs >> 14 days later','R goes from 2.6 to 0.6 at >> lockdown'});legend('Infected','Recovered','Hospitalised','Total Cases'); > -- > 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 > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: