Re: [Scilab-users] Converting string months to month numbers

2016-10-20 Thread Mike Page
Hi Jens,

grep does something like what you want.

-->[r,w]=grep(Ms,M);
-->matrix(w,size(Ms))
 ans  =

12.4.
2. 12.
6. 7.

Not sure why grep produces a vector when searching for a matrix, but it
seems that way.

HTH,
Mike.


On 20 October 2016 at 10:32, Jens Simon Strom  wrote:

> Hallo,
> Given the string vector
>
> M=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
> which implicitly maps the string representation of the months to their number 
> representataion I would like to map any string matrix containing elements of 
> M into a numercal matrix showing the month numbers.
> E. g.
> Ms=['Dec','Apr';'Feb','Dec';'Jun','Jul']
> should be converted to
> Mn=[12,4;2,12;6,7].
>
> Ho can that be done in a vectorial style?
>
> Backward (given Mn) it is easier to me:Ms=matrix(M(Mn),size(Mn))
>
> Regards
> Jens
>
>
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Scilab control after an impossible calculation

2016-10-06 Thread Mike Page
Hi Paul,

Would Scilab's try-catch block do what you want?  For example:

for i=1:10;
   try;
  disp(1/(i-5));
   catch;
  disp("err");
   end;
end

won't crash when it gets to the divide by zero.

This is the more structured way, but you can use execstr with errcatch to
do the same thing.

HTH
Mike.


On 6 October 2016 at 09:51,  wrote:

> Hi All
>
>
>
> I’m using Scilab as the interface between my optimizer and my finite
> element solver(s) and sometimes Scilab stops because of unexpected and
> impossible calculus (1/x with x = 0 as an example ); obviously Scilab stops
> (and so the optimization).
>
>
>
> I’m wondering if it’s possible:
>
> -  To ask back Scilab a message such as “hey I crashed because
> you’re a fool and you’ve not anticipated an impossible calculation !!!”
>
> -  To get back Scilab control in order to avoid optimization
> process crash ? I’ve been thinking in affecting a cost function value at
> %inf for example (not elegant I recognize)
>
>
>
> I don’t know if I’m understandable enough …
>
>
>
> Paul
>
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Envelop of a noisy curve

2015-04-24 Thread Mike Page
Hi Paul,

Usually the envelope is calculated via the magnitude of the Hilbert
transform.  Check out Hilbert in the help.  As usual there are some
caveats, but often this is close enough without further work.

HTH,
Mike.


On 24 April 2015 at 13:05,  wrote:

> Dear All,
>
> I am absolutly not familiar with "signal processing" field, so my question
> is probably naïve: how can I proceed to get the envelop curve (maximum
> values) of a non periodic noisy signal ?
>
> Thanks for any suggestion
>
> Have a good WE
>
> Paul
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Pb to launch DotNetScilab C# example project

2015-04-15 Thread Mike Page
Hi Pascal,

Not sure about DotNet, but some time ago I reported a problem with this API
for C (not c#) because the third parameter is specified as int*, but is in
fact int.  If your compiler is fussy, this could be the problem.  Try
(NULL, NULL, 0).  I found that fixed it for me.

Hope that helps,
Mike.


On 14 April 2015 at 17:53,  wrote:

>  Hello
>
> I am on windows 8.1 and visual studio 2010, I am interested in using
> DotNetScilab with C#, but when I want to run the project given as example
>
> it stops at
> // start Scilab engine
> Scilab_cs_wrapper.StartScilab(null, null, null);
>
> with the message
> Attempt to load a program with uncorrect format
>
> on the same machine, I run a win32 call_scilab program with no problem
>
> Thanks in advance for any suggestion/help
> pascal
>
>
>
>
>
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] [help] converting a simple C code to Scilab

2014-05-02 Thread Mike Page
Hi,

vet = 1:4;
disp (vet(3));

will do almost the same thing.  But note that Scilab indices start at 1, not
zero, so vet does not include the element vet[0] = 0;

HTH,
Mike.


-Original Message-
From: users [mailto:users-boun...@lists.scilab.org]On Behalf Of
Alessandro Schmitt
Sent: 02 May 2014 00:41
To: users@lists.scilab.org
Subject: [Scilab-users] [help] converting a simple C code to Scilab


Hi, how would this be written using scilab?

   int vet[10];
   int i=0;

   do
   {
   vet[i]=i;
   i++;
   }
   while (i<5);

printf("%i",vet[3]); //prints the number 3

Thanks.



--
View this message in context:
http://mailinglists.scilab.org/help-converting-a-simple-C-code-to-Scilab-tp4
030411.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4577 / Virus Database: 3931/7425 - Release Date: 05/01/14

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] finding similar values with scilab

2014-02-21 Thread Mike Page
Hi,

If you want to remove outliers from a data set, you can use the modified
Thompson Tau method.  Basically tau provides a limit based on mean and
standard deviation so that values outside (mean +/- n * std dev) are
rejected.  The method is unfortunately iterative, but it works well.  You
can remove the located outliers using something like x = x(find(delta < tau
* sd)), where delta is the absolute difference from the mean.

Hope that helps,
Mike.


-Original Message-
From: users [mailto:users-boun...@lists.scilab.org]On Behalf Of
samaelkreutz
Sent: 21 February 2014 05:18
To: users@lists.scilab.org
Subject: [Scilab-users] finding similar values with scilab


Hello!!! I have a big question !
I have a biiig data archive with text files with the form:

18.87 2.6 0.00545558
19.98 2.6 0.00225349
18.87 2.6 0.00405905
13.32 2.6 0.01338288
19.98 2.6 0.01537532
18.87 2.6 0.00481375
19.98 2.6 0.00936207
12.21 2.6 0.00558517

I need  eliminate extreme values, for example: If I plot a random text file
I obtain a image like this:



As you can see theres points extremes. If i make a zoom

DN=find(DM(:,3)<=0.0001 & DM(:,3)>=0.2 )
dn=DM(DN,:)
figure(2)
plot(dn(:,1),dn(:,3),'O')

I have this picture




My question is: Has scilab a command that can help me to find the "dense
data" , I mean find all the values that are similar. I ask this cause I have
about 20,000 text files and is imposible for me make "artesal zoms".

Please any suggestion, answer going to help me.




--
View this message in context:
http://mailinglists.scilab.org/finding-similar-values-with-scilab-tp4028792.
html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4335 / Virus Database: 3705/7111 - Release Date: 02/20/14

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Help with text files

2013-11-26 Thread Mike Page
Hi Eduardo,

Sometimes I have had problems like this due to line termination characters.
It's possible if a file gets moved from Linux to Windows and back again, it
can get unexpected CR or LF characters.  Sometimes these are read as a
garbage line.  I would take a look at your text file with a hex editor to
make sure the line terminations are what you expect.  Unfortunately as the
file you attached got sent via email I can't tell from looking at it what
was in your original file.

What happens when you try to read the next line?

HTH,
Mike.

  -Original Message-
  From: users [mailto:users-boun...@lists.scilab.org]On Behalf Of Eduardo
Torrecillas
  Sent: 26 November 2013 19:43
  To: International users mailing list for Scilab.
  Subject: Re: [Scilab-users] Help with text files




  Hi Paul,

  Using phrase=mgetl(fd) turns into the same result:

   phrase  =

   ÿþ



  Regards,




  On Tue, Nov 26, 2013 at 5:22 PM, Paul Carrico 
wrote:

Try basicaly …

phrase=mgetl(fd)

then you’ve an array of characters …



Paul







De : users [mailto:users-boun...@lists.scilab.org] De la part de Eduardo
Torrecillas
Envoyé : mardi 26 novembre 2013 19:14
À : International users mailing list for Scilab.
Objet : [Scilab-users] Help with text files



Hello all,

I currently have some text files and I would like to extract information
from them using Scilab.
I have done this before, using mopen and mgetl, for example.

Don't know why, but strangely in this case it is not working. I am using
Scilab 5.4.1 on Ubuntu (but Scilab 5.4.0 under Windows produced the same
result).

Please check the attached text file.

Simple code such as:

fd=mopen('scilab_example.txt','r')

phrase=mgetl(fd,1)

Produces:

phrase=ÿp

If i still try to use mgetl, next lines are always returned as empty.

Does anybody have any clue on whats happening?

Best regards,



--
Eduardo Torrecillas
AER-09





Ce courrier électronique ne contient aucun virus ou logiciel
malveillant parce que la protection Antivirus avast! est active.




___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users





  --
  Eduardo Torrecillas
  AER-09
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Levenberg-Marquardt algorithm

2013-09-18 Thread Mike Page
Hi,

I have been using the Levenberg-Marquardt solver (lsqrsolve), but would like
to look at ways to adjust it to better suit my particular problem.  Does
anyone know if the souce code for this is available anywhere and if it is in
fact open source?

Thanks,
Mike.




--
View this message in context: 
http://mailinglists.scilab.org/Levenberg-Marquardt-algorithm-tp4027433.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Colorbar_same color code, different graphs

2013-07-22 Thread Mike Page
Hi Larissa,

Sorry, but I don't know how to do what you want.  As far as I know, when you 
assign a colormap to a figure, the colors span across the range of the data (so 
zmax = red and zmin = blue for example).  I think you want them to span across 
the data bounds of the figure, but I don't know how to do that.

The idea I mentioned before will produce a colorbar that spans the right set of 
colors and has the right legend, but I don't know how to get the colors on the 
figure right.  I'm sure it can be done some way, but I don't know how.  Perhaps 
you could add an artificial point to your data to make it span the full range?

Mike.

  -Original Message-
  From: users-boun...@lists.scilab.org 
[mailto:users-boun...@lists.scilab.org]On Behalf Of Larissa Schultze
  Sent: 22 July 2013 13:24
  To: mike.page...@googlemail.com
  Cc: International users mailing list for Scilab.
  Subject: [Scilab-users] Colorbar_same color code, different graphs


  Hi everybody,

  thank you a lot for your reply, Mike.
  The suggestion sounds really good, but I couldn't make it work yet, 
unfortunately.
  So again, for the table:

  Nan 0. 20. 60. 100.140.180.200.  
  0.  Nan0.  Nan Nan Nan Nan Nan   
  5.  Nan68. 73. 61. 63. 67. Nan   
  40. Nan17. 9.  10. 12. 17. Nan   
  75. Nan14. 7.  6.  6.  12. Nan   
  110.Nan15. 6.  4.  6.  21. Nan   
  145.Nan21. 28. 26. 20. 34. Nan   
  150.NanNan Nan Nan Nan Nan Nan 


  I used the following commands:

  "
  [fd,SST,Sheetnames,Sheetpos] = xls_open('E:\XX.xls')
  Sheets = readxls('E:\XXX.xls');
  typeof(Sheets);
  s1=Sheets(1);
  data=s1.value;
  x=data(1,2:8);
  y=data(2:8,1);
  z=data(2:8,2:8);
  xx = linspace(0,200,200);
  yy = linspace(0,150,200);
  [xp,yp] = ndgrid(xx,yy);
  zp = linear_interpn(xp,yp, x, y, z);
  clf();
  surf(xx,yy,zp);
  f=get("current_figure");
  f.color_map=jetcolormap(512);
  h=get("hdl") //get handle on current entity (here the surface)
  h.color_flag=1;
  a=gca();
  a.auto_scale="off";
  a.tight_limits="on";
  a.data_bounds=[0,0,0;200,150,1300]
  colorbar(0,1300);
  "

  Still, the colors in the figure do not correspond to those of the colorbar. I 
mean, according to the colorbar, this dataset should have basically different 
dark blue tones...and that is what I am aiming at. ...but...how can I possibly 
make it work? Can anybody help me please?
  It would be great

  thank you in advance and kind regards,
  Larissa







  Gesendet: Dienstag, 16. Juli 2013 um 11:09 Uhr
  Von: "Mike Page" 
  An: "International users mailing list for Scilab." 
  Betreff: Re: [Scilab-users] Colorbar_same color code, different graphs
  Hi Larissa,

  I'm no expert on this, but have you tried changing the data_bounds for the 
figure's children independently?  I think if you just set the colorbar limits 
with colorbar(a,b), that only changes the legend on the bar itself.

  Try f=gcf(); then look at f.children(1),data_bounds or 
f.children(2).data_bounds.  I think one will be for the plot and the other for 
the colorbar.  If you change these limits directly you may get the effect you 
are looking for.

  Sorry if I misunderstood your question.

  Mike.

-Original Message-
From: users-boun...@lists.scilab.org 
[mailto:users-boun...@lists.scilab.org]On Behalf Of Larissa Schultze
Sent: 16 July 2013 08:48
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] Colorbar_same color code, different graphs
 
Hello everyone, 

I have to plot several graphs with measurements ranging from 6 to 1300. I 
would like that these graphs obey the same color code, so that, in the example 
of jetcolormap, "1300" would always be dark red and "0" would always be dark 
blue for each graph. Now the values that I have for the different graphs are 
quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 
has values between "600" and "1300".

How can I manage that the colorbar and the colorcode for both these graphs 
remains the same? (in this case, graph 1 would presumably have only a gradient 
of dark blue colors and graph 6 would have rather orange to red colors)
I tried changing the command of colorbar to "colorbar(0,1300)", but it 
didn't work at all...so I thought may be someone could give me a hint on how I 
would be able to align the color code these graphs...

I put an example of my tables on the annex as well as the scilab commands 
that I have been using for that. I simply need the

Re: [Scilab-users] Colorbar_same color code, different graphs

2013-07-16 Thread Mike Page
Hi Larissa,

I'm no expert on this, but have you tried changing the data_bounds for the 
figure's children independently?  I think if you just set the colorbar limits 
with colorbar(a,b), that only changes the legend on the bar itself.

Try f=gcf(); then look at f.children(1),data_bounds or 
f.children(2).data_bounds.  I think one will be for the plot and the other for 
the colorbar.  If you change these limits directly you may get the effect you 
are looking for.

Sorry if I misunderstood your question.

Mike.

  -Original Message-
  From: users-boun...@lists.scilab.org 
[mailto:users-boun...@lists.scilab.org]On Behalf Of Larissa Schultze
  Sent: 16 July 2013 08:48
  To: International users mailing list for Scilab.
  Subject: Re: [Scilab-users] Colorbar_same color code, different graphs


  Hello everyone, 

  I have to plot several graphs with measurements ranging from 6 to 1300. I 
would like that these graphs obey the same color code, so that, in the example 
of jetcolormap, "1300" would always be dark red and "0" would always be dark 
blue for each graph. Now the values that I have for the different graphs are 
quite diverse: graph 1 has values ranging between "6" and "68" whereas graph 6 
has values between "600" and "1300".

  How can I manage that the colorbar and the colorcode for both these graphs 
remains the same? (in this case, graph 1 would presumably have only a gradient 
of dark blue colors and graph 6 would have rather orange to red colors)
  I tried changing the command of colorbar to "colorbar(0,1300)", but it didn't 
work at all...so I thought may be someone could give me a hint on how I would 
be able to align the color code these graphs...

  I put an example of my tables on the annex as well as the scilab commands 
that I have been using for that. I simply need the values of both tables to be 
registered according to one color code (1300=dark red, 6=dark blue)...I would 
appreciate it a lot if someone could help me. :) 

  Thank you guys in advance
  Larissa
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Convert x, y, z data into a z=f(x,y) function

2013-07-01 Thread Mike Page
Hi,

You are asking a question which in general has no answer.  There are an 
infinite number of models which can fit your data.  You need to find some 
possible candidate model forms based on physical properties and then try 
fitting to them.  You are probably looking for a fit which leaves residues 
which are Gaussian and mean zero (but that's not always true...).

Try giving us a clue about where the data come from.  Maybe somebody has the 
physical background to suggest some models.  If not, try plotting the data and 
guessing a model from the shape.  To me the shape looks vaguely exponential or 
logarithmic, so maybe plotting as log-linear or log-log will give a clue.

HTH,
Mike.

  -Original Message-
  From: users-boun...@lists.scilab.org 
[mailto:users-boun...@lists.scilab.org]On Behalf Of Larissa Schultze
  Sent: 01 July 2013 09:43
  To: International users mailing list for Scilab.
  Subject: Re: [Scilab-users] Convert x, y, z data into a z=f(x,y) function


  Hello all,

  first of all, thanks a lot for your effort. I must say that I don't really 
have anyone to run to for asking about mathematical models - I could go to the 
mathematicians at the University, but I don't know anyone there and I barelly 
know where the institute is located...

  therefore I decided to insert my simplest table in here (it is actually very 
simple) - may be someone here knows which kind of mathematical model I could 
use?
  I have been searching for it in literature, but I don't seem to be in the 
right path...

  So attached you will find my data table as well as the scilab commands I used 
to create the respective graph. I mean, my data is already 
interpolated...shouldn't it be easy to get a function (z,x,y) out of it?

  I would be very very thankful for any help...I'm getting a bit desperate...

  best regards,
  Larissa




  Gesendet: Dienstag, 25. Juni 2013 um 11:09 Uhr
  Von: "CRETE Denis" 
  An: "International users mailing list for Scilab." 
  Betreff: Re: [Scilab-users] Convert x, y, z data into a z=f(x,y) function
  Hello,

  The general procedure for fitting data in the case of 2 variables is the 
following:
  // First define your mathematical model by changing the following line
  deff('z=MyFunction(x,y)', 'z=p(1)*x + p(2)*y + p(3)*x.*y');
  // Store all experimental data in a single array ExD; X, Y, Z assumed to be 1 
x NZ vectors
  ExD=[X;Y;Z];
  // Define the error function (to be minimized with respect to the parameters 
p)
  deff('erro=G(p,ExD)','x=ExD(1),y=ExD(2), z=ExD(3), erro=z-MyFunction(x,y)')
  // Fit experimental data contained in W
  // The column vector p0 is an initial guess of the values for the parameters 
of your Model
  [p,err]=datafit(G,ExD,p0)
  // you can check values generated with
  MyFunction(X,Y)

  HTH
  Denis

  -Message d'origine-
  De : users-boun...@lists.scilab.org [mailto:users-boun...@lists.scilab.org] 
De la part de Dang, Christophe
  Envoyé : mardi 25 juin 2013 10:20
  À : International users mailing list for Scilab.
  Objet : Re: [Scilab-users] Convert x, y, z data into a z=f(x,y) function

  Hello,

  De la part de Larissa
  Envoyé : mardi 25 juin 2013 09:52

  > I conducted an experiment and thus my results are composed of x,y,z
  > data,
  [...]
  > but I can't figure out how to get an equation "z=f(x,y)" out of it.

  This is more a math problem than a Scilab problem.

  You must have a mathematical model, i.e. a parametric formula, then you can 
adjust the parameters by regression (or maximum likehood).

  You may have theoretical models that derive from elementary assumptions
  -- you usually find such model in the bibliography --, or use a "nice model 
that fit the global shape"
  -- you may ask the math laboratory in your neighbourhood, this is usually 
polynomials, exponentials, statistical laws...

  So if you come to us with a parametric model, we will be able to help you.

  best regards.

  --
  Christophe Dang Ngoc Chan
  Mechanical calculation engineer

  __

  This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error), please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden.
  __
  ___
  users mailing list
  users@lists.scilab.org
  http://lists.scilab.org/mailman/listinfo/users
  ___
  users mailing list
  users@lists.scilab.org
  http://lists.scilab.org/mailman/listinfo/users___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] non access to sci files

2013-04-12 Thread Mike Page
Hi,

I tried Sci2C once (a while ago now), but I found it had too many
limitations.  For me the lack of support for hypermatrices was enough to
make it not usable.  There is (I think) an example of Sci2C that shows how
it works, but I don't remember where - sorry.

One other way to solve your problem is to use SendScilabJob.  This enables
you to send Scilab commands from C code to the Scilab engine.  I use this
quite a lot.  Then your Scilab code would only exist as a set of string
constants inside C and could be compiled and hidden.

I posted an example of using SendScilabJob a while back - you can search the
user group for "sendscilabjob" and you will find all the threads.

HTH,
Mike.


-Original Message-
From: users-boun...@lists.scilab.org
[mailto:users-boun...@lists.scilab.org]On Behalf Of Carrico, Paul
Sent: 12 April 2013 09:53
To: International users mailing list for Scilab.
Subject: Re: [Scilab-users] non access to sci files


Hi

It's look promissing ... I installed it but i'm spending a lot of time in
finding some docs / help file and so on ...

Where are they ?

Cheers

Paul

-Message d'origine-
De : users-boun...@lists.scilab.org [mailto:users-boun...@lists.scilab.org]
De la part de David Chèze
Envoyé : vendredi 12 avril 2013 09:34
À : users@lists.scilab.org
Objet : Re: [Scilab-users] non access to sci files

Hi Paul,

did you already have a look at:
http://atoms.scilab.org/toolboxes/scilab2c

I've never used this module and i assume there are some limitations but it's
worth giving a try...

David




--
View this message in context:
http://mailinglists.scilab.org/Scilab-users-non-access-to-sci-files-tp402650
8p4026525.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users




Le présent mail et ses pièces jointes sont confidentiels et destinés à la
personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail
par erreur, veuillez contacter immédiatement l'expéditeur et effacer le
message de votre système. Toute divulgation, copie ou distribution de cet
e-mail est strictement interdite.

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error, please contact the sender and
delete the email from your system. If you are not the named addressee you
should not disseminate, distribute or copy this email.

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3272 / Virus Database: 3162/6239 - Release Date: 04/11/13


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] discrete Fourier transform

2013-03-21 Thread Mike Page
Hi,

I think this is just a question of scaling.  There is no "correct" scaling
for the FFT - just some different conventions.  This is explained here
(http://www.mathworks.co.uk/matlabcentral/answers/15770-scaling-the-fft-and-
the-ifft).

The "correct" answer with Scilab would be exactly 100 (N/2) in your case,
but you have a small error because your waveform is not exactly periodic -
the first and last sample are the same, but you should have the last sample
being the one before the first sample for a complete cycle.

The following code does that:

-->n=201;

-->x=linspace(0,2*%pi,n);

-->x=x(1:200);

-->y=sin(x);

-->Xf=dft(y,-1);

-->XfA = abs(Xf);

-->XfA(2)
 ans  =

100.

HTH,
Mike.


-Original Message-
From: users-boun...@lists.scilab.org
[mailto:users-boun...@lists.scilab.org]On Behalf Of haasejos
Sent: 21 March 2013 21:14
To: users@lists.scilab.org
Subject: Re: [Scilab-users] discrete Fourier transform


-->n = 200;

-->x=linspace(0,2*%pi,n);

-->y=sin(x);

-->Xf=dft(y,-1);

-->XfA = abs(Xf); *please look at the difference! *
-->XfA(2)
 ans  =

99.745189



--
View this message in context:
http://mailinglists.scilab.org/discrete-Fourier-transform-tp4026318p4026326.
html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3267 / Virus Database: 3160/6194 - Release Date: 03/21/13

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Error in Nelder-Mead functions

2013-03-13 Thread Mike Page
I have just checked on Scilab 5.3.2 and found this works on that version, so
it looks like a bug.

Mike.


-Original Message-
From: users-boun...@lists.scilab.org
[mailto:users-boun...@lists.scilab.org]On Behalf Of Mike Page
Sent: 13 March 2013 13:52
To: users@lists.scilab.org
Subject: [Scilab-users] Error in Nelder-Mead functions


Hi,

I am trying to use the Nelder Mead optimisation functions to fit a
biological model to some experimental data.  I am using Scilab 5.4.0 on Win
XP.

The search halts with the error:

 !--error 21
Invalid index.
at line  78 of function neldermead_updatesimp called by :
at line  26 of function neldermead_autorestart called by :
at line  22 of function neldermead_search called by :
at line  37 of function CpeFit called by :
at line  13 of function TestFit called by :
TestFit

This line in neldermead_updatesimp seems to be "str = string ( simplex0 )".

If I turn on verbose mode, the problem happens here:


Function Evaluation #42, index=2, x= [134014.18 0.0001 0.7648109 134014.18
0.012 0.7648109 134014.18 0.506 0.7648109 97.463]
Function Evaluation #43, index=2, x= [134014.18 0.0001 0.7648109 134014.18
0.012 0.7648109 134014.18 0.012 0.7648603 97.463]
Function Evaluation #44, index=2, x= [134014.18 0.0001 0.7648109 134014.18
0.012 0.7648109 134014.18 0.012 0.7648109 97.462951]
Before scaling:
Optim Simplex Object:
=
nbve: 11
n: 10
x: 11-by-10 matrix
fv: 11-by-1 matrix
 !--error 21


The Nelder Mead setup is as follows:

nm = neldermead_new ();
nm = neldermead_configure (nm, "-method", "box");
//nm = neldermead_configure (nm, "-verbose", 1);
nm = neldermead_configure (nm, "-numberofvariables", 10);
nm = neldermead_configure (nm, "-maxfunevals", 1000);
nm = neldermead_configure (nm, "-maxiter", 1000);
nm = neldermead_configure (nm, "-restartflag", %t);
nm = neldermead_configure (nm, "-boxtermination", %t);
nm = neldermead_configure (nm, "-function", CpeLossFunc);
nm = neldermead_configure (nm, "-boundsmin", ...
[1.0E3; 1.0E-9; 0.1; 1.0E3; 1.0E-9; 0.1; 1.0E3; 1.0E-9; 0.1; 10.0]);
nm = neldermead_configure (nm, "-boundsmax", ...
[10.0E6; 100.0E-6; 0.9; 10.0E6; 100.0E-6; 0.9; 10.0E6; 100.0E-6;
0.9; 10.0E3]);
nm = neldermead_configure (nm, "-x0", Values);
nm = neldermead_search (nm);
Values = neldermead_get (nm, "-xopt");
disp (neldermead_get (nm, "-status"));
nm = neldermead_destroy (nm);

Anyone have any ideas what is wrong?

Cheers,
Mike.

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


-
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6168 - Release Date: 03/12/13

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Error in Nelder-Mead functions

2013-03-13 Thread Mike Page
Hi,

I am trying to use the Nelder Mead optimisation functions to fit a
biological model to some experimental data.  I am using Scilab 5.4.0 on Win
XP.

The search halts with the error:

 !--error 21
Invalid index.
at line  78 of function neldermead_updatesimp called by :
at line  26 of function neldermead_autorestart called by :
at line  22 of function neldermead_search called by :
at line  37 of function CpeFit called by :
at line  13 of function TestFit called by :
TestFit

This line in neldermead_updatesimp seems to be "str = string ( simplex0 )".

If I turn on verbose mode, the problem happens here:


Function Evaluation #42, index=2, x= [134014.18 0.0001 0.7648109 134014.18
0.012 0.7648109 134014.18 0.506 0.7648109 97.463]
Function Evaluation #43, index=2, x= [134014.18 0.0001 0.7648109 134014.18
0.012 0.7648109 134014.18 0.012 0.7648603 97.463]
Function Evaluation #44, index=2, x= [134014.18 0.0001 0.7648109 134014.18
0.012 0.7648109 134014.18 0.012 0.7648109 97.462951]
Before scaling:
Optim Simplex Object:
=
nbve: 11
n: 10
x: 11-by-10 matrix
fv: 11-by-1 matrix
 !--error 21


The Nelder Mead setup is as follows:

nm = neldermead_new ();
nm = neldermead_configure (nm, "-method", "box");
//nm = neldermead_configure (nm, "-verbose", 1);
nm = neldermead_configure (nm, "-numberofvariables", 10);
nm = neldermead_configure (nm, "-maxfunevals", 1000);
nm = neldermead_configure (nm, "-maxiter", 1000);
nm = neldermead_configure (nm, "-restartflag", %t);
nm = neldermead_configure (nm, "-boxtermination", %t);
nm = neldermead_configure (nm, "-function", CpeLossFunc);
nm = neldermead_configure (nm, "-boundsmin", ...
[1.0E3; 1.0E-9; 0.1; 1.0E3; 1.0E-9; 0.1; 1.0E3; 1.0E-9; 0.1; 10.0]);
nm = neldermead_configure (nm, "-boundsmax", ...
[10.0E6; 100.0E-6; 0.9; 10.0E6; 100.0E-6; 0.9; 10.0E6; 100.0E-6;
0.9; 10.0E3]);
nm = neldermead_configure (nm, "-x0", Values);
nm = neldermead_search (nm);
Values = neldermead_get (nm, "-xopt");
disp (neldermead_get (nm, "-status"));
nm = neldermead_destroy (nm);

Anyone have any ideas what is wrong?

Cheers,
Mike.

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Emulate Object Oriented Programming

2012-11-27 Thread Mike Page
You could of course "define constants" in Scilab.  This is what I usually do:

[NONE, CONTINUOUS, DISCRETE, FFT] = (1, 2, 3, 4);

OK - not perfect, but it makes code more readable.

HTH,
Mike.


-Original Message-
From: users-boun...@lists.scilab.org
[mailto:users-boun...@lists.scilab.org]On Behalf Of
michael.bau...@contrib.scilab.org
Sent: 27 November 2012 09:08
To: users@lists.scilab.org
Subject: Re: [Scilab-users] Emulate Object Oriented Programming


Hi,

Thank you Serge for this interesting script.
Defining a tlist with unnamed fields is indeed an idea which
is quite unusual !

You will find in attachment a modified version, merging your proposal 
and my
previous attempt.

On the user's side, the "object" can now produce messages such as:

-->bob.weight=-5
  !--error 1
Expect nonnegative weight.
at line  18 of function %s_i_THUMAN called by :
bob.weight=-5

which is excellent.

On the developper's side, the "set" function (which is
called insertion in the overloading vocabulary), is now
much less clear, because fields are now identified with
their index (i.e. 1, 2, 3,...) instead of their name
(i.e. "name", "weight", ...).

For example, this is the code to set the "weight" field:

function h=%s_i_THUMAN(field,value,h)
[...]
 select field
 case "weight"
[...]
 if (value<0) then
 error("Expect nonnegative weight.")
 end
 h(4)=value
[...]

So this is not an ideal solution: it has some advantages for the
users, but is much more difficult for the developper.
It is a huge source of bugs, for example if we mix up the
indices: e.g. 2 instead of 4 will set the "name" instead of the
"weight".
In the C language, we would #define constants to these indices,
so that we can avoid this problem.
But this is Scilab, not C.

Isn't there a simpler way ?
In other words, couldn't we get the named fields both from the
user's and the developper's sides ?

Best regards,

Michaël

Le 2012-11-26 19:09, Serge Steer a écrit :
> For safe mode you can use tlist with no field names. See the example
> in the attached file
>
> Serge Steer
>
> -
>
>> DE: "Daniel Penalva" 
>> À: "International users mailing list for Scilab." 
>> 
>> ENVOYÉ: Dimanche 25 Novembre 2012 23:04:56
>> OBJET: Re: [Scilab-users] Emulate Object Oriented Programming
>>
>> Hi,
>>
>> By safe you mean that the field is protected or private ? i dont 
>> know if it is possible in scilab nowadays ...
>>
>> [ ]s
>>
>> On Sun, Nov 25, 2012 at 7:28 PM,  
>> wrote:
>>
>>> Hi,
>>>
>>> I have a problem with the possibility of emulating OOP in Scilab 
>>> with
>>> tlists, that prevents me to have safe "set" methods.
>>> In the script in attachment, I created a human "class" with
>>> two fields: name (a scalar string) and weight (a scalar real).
>>>
>>> The problem is : how have a "set" method which is both simple and 
>>> safe ?
>>>
>>> Here is how this class works :
>>>
>>> bob=human_new()
>>>
>>> This is simple, but is unsafe:
>>>
>>> bob.name [1]="Bob"
>>> bob.weight=70
>>> bob.name [1]=-12 // Oups !
>>>
>>> These statements are safe:
>>>
>>> bob=human_set(bob,"name","Will")
>>> bob=human_set(bob,"weight",80)
>>>
>>> It is safe in the sense that the following statements produce an 
>>> error:
>>>
>>> bob=human_set(bob,"weight",-12)
>>>
>>> The function "human_set" is safe but somewhat unconvenient to use.
>>>
>>> The question is :
>>>
>>> How to make so that bob.name [1]="Will" makes the code 
>>> bob=human_set(bob,"name","Will") be executed ? Can overloading do 
>>> this ?
>>>
>>> Is the only possible way is at the C level with the sci_percent* 
>>> functions that Denizet wrote :
>>>
>>> 
>>> http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/xml/sci_gateway/cpp/sci_percent_XMLAttr_size.cpp;h=9d3b361bcbe6416e62f422dd448aa72d65f1fe4c;hb=HEAD
>>>  
>>> [2]
>>>
>>> for the XML module ?
>>>
>>> Best regards,
>>>
>>> Michaël
>>>
>>> ___
>>> users mailing list
>>> users@lists.scilab.org
>>> http://lists.scilab.org/mailman/listinfo/users [3]
>>
>> --
>> Democracia Digital Direta
>> Carta:
>>
>> http://li7e.org/ddd2 [4]
>>
>> Des Carta coletiva aos ministerios
>> 
>> http://rede.metareciclagem.org/blog/16-10-12/Des-Carta-da-Rede-Metareciclagem-para-o-Ministerio-da-Cultura-e-Outros-Ministerios-Tam
>>  
>> [5]
>>
>> AFROAMBIENTAL EH SOCIEDADE EM AXE E DIVERSIDADE
>>
>> http://afroambiental.org [6]
>>
>> Daniel Penalva
>>
>> State related activity, currently:
>> Phd - Physics in Institute for Theoretical Physics - 
>> http://www.ift.unesp.br/posgrad/ramais-alunos-pos.php [7]
>>
>> Transparency portal(workflows): 
>> http://www.nightsc.com.br/aa/interface_v0.1.php [8] *look for SUoU9 
>> user, or do ctrl+f and SUoU9*
>>
>> FLOSS and related ideas enthusiastic
>>
>> ___
>> users mailing list
>> users@lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
>
>
> Links:
> --
> [1] 

Re: [Scilab-users] LInear interpolation between 2 curves

2012-09-17 Thread Mike Page
Hi Paul,

Assuming the relationship between x, y and T is approximately linear, then
you can just match the points on the curves pairwise and interpolate between
the pairs using interpln.  If your target temperature T is such that T = aT1
+ (1-a)T2, then it will produce a point at abscissa x = ax1 + (1-a)x2 and
ordinate y = ay1 + (1-a)y2, where (x1,y1) and (x2,y2) are one of the pairs
of points.  You can build up the two x and y vectors and plot using plot2d.

This is usually only useful between your two temperatures (interpolation)
and is of limited accuracy outside (extrapolation), but that depends...

If you need to get the result on a defined abscissa grid, then you can
interpolate in the x and y directions separately, noting that sometimes it
makes a difference which order you do this in.  Depending on the spacing of
your x points, a linear interpolation in the x direction may not be accurate
enough.  In that case, I would use for example a Lagrange interpolation.

HTH,
Mike.

  -Original Message-
  From: users-boun...@lists.scilab.org
[mailto:users-boun...@lists.scilab.org]On Behalf Of Carrico, Paul
  Sent: 17 September 2012 08:54
  To: users@lists.scilab.org
  Subject: [Scilab-users] LInear interpolation between 2 curves


  Dear all,

  Is it possible to make a linear interpolation between 2 curves ? note the
abscissa are not necessary exactly the same  ...

  In particular terms, I've a curve one at temperature X and another one at
température Y and I would like to have (and to plot) temperature at
temperature Z in-between X-Y ... (see attachment)

  I had a look in interp, interp1 and interpln but nothing sound useful for
me ... Am I wrong ?

  Thanks for any advice

  Paul




Le présent mail et ses pièces jointes sont confidentiels et destinés à la
personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail
par erreur, veuillez contacter immédiatement l'expéditeur et effacer le
message de votre système. Toute divulgation, copie ou distribution de cet
e-mail est strictement interdite.

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error, please contact the sender and
delete the email from your system. If you are not the named addressee you
should not disseminate, distribute or copy this email.

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users