[scilab-Users] How to automatically increase matrix name number

Mike Page Mike at Page-One.Waitrose.com
Fri Sep 24 12:38:15 CEST 2010


You need to put all of the line into the string before execstr, like:

-->for i = 1 : 10
-->    newstr = "A = A + matrix" + string(i);
-->    execstr(newstr);
-->end

-->A
 A  =

    10.    20.    30.    40.

(You also have mistyped newstr as mewstr :-)

HTH
Mike.

  -----Original Message-----
  From: Carrico, Paul [mailto:paul.carrico at esterline.com]
  Sent: 24 September 2010 11:04
  To: users at lists.scilab.org
  Subject: RE: [scilab-Users] How to automatically increase matrix name
number


  I think I do not understand something ... can somebody tell me what I'm
doing wrong ?

  Thanks in advance

  Paul




############################################################################
##########

  mode(0)
  clear all

  // creation of the matrix
  for j = 1 : 10
      mystr2="matrix"+string(j)+"=[1 2, 3 4]";
      execstr(mystr2)
  end


  // verification that matrix1, matrix2 and so on are variables/declared
  printf("\n the matrix are manually print on the sreen\n")
  matrix1
  matrix2
  matrix3

  // print of all the matrix throughout a loop
  printf("\n print of the matrix on the sreen using a loop\n")
  for i = 1 : 10
      execstr("disp(matrix" + string(i)+")");
  end


  // test to validate that calculations can be performed why the previous
matrix
  A = []
  for i = 1 : 10
      mewstr = "matrix" + string(i);
      A = A + execstr(newstr);
  end

  A




----------------------------------------------------------------------------
--
  De : Antoine Monmayrant [mailto:antoine.monmayrant at laas.fr]
  Envoyé : vendredi 24 septembre 2010 10:24
  À : users at lists.scilab.org
  Objet : Re: [scilab-Users] How to automatically increase matrix name
number


  Le 24/09/2010 10:05, Carrico, Paul a écrit :
    All,

    In a loop I would like to create several matrix but their size as well
as their number/name number depend on the file results (they're
automatically created).

    Is it possible that the name number becomes a variable ?

    for i = 1 : n
        creation of A1[] / A2[] / A3[] .... An[]
    end for

    Please note each matrix size may be different


    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.

  Here is an example:

  i=10;mystr="matrix_"+string(i)+"=[1 2, 3 4]";execstr(mystr);

  Once you've ran it, matrix_10 is created and contains [1 2, 3 4].

  Antoine


----------------------------------------------------------------------------
----


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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20100924/7a416600/attachment.htm>


More information about the users mailing list