On 05/06/2013 10:58, Carrico, Paul wrote:
Dear All
How can I mix strings and doubles in a matrix ?
Example :
string_matrix = [ 'a' ; 'b' ; 'c']
double_matrix = [ 1 ; 2 ; 3]
mixed_matrix = [string_matrix double_matrix]
hi
mixed_matrix = [string_matrix string(double_matrix)]
i generally "configure" scila to do this automatically, and other useful
stuff with these functions:
Exported from Notepad++
//2*"hey " = "hey hey "
functionstr=stringmult(nb,str0)str=emptystr(str0);ifsize(nb)==size(str0)thenfori=1:size(nb,1)forj=1:size(nb,2)fork=1:nb(i,j)str(i,j)=str(i,j)+str0(i,j);endendendelsemkalert("error");error("stringmult:
sizes don''t match");endendfunction//defines 2*"hey"="heyhey"
functionx=%s_m_c(a,b)x=stringmult(a,b)endfunction//defines"hey "*2="hey
hey " functionx=%c_m_s(a,b)x=stringmult(b,a)endfunction//defines
"string"+5 ="string5"
functionx=%c_a_s(a,b)x=a+string(b)endfunction//defines 5+" string" ="5
string"
functionx=%s_a_c(a,b)x=string(a)+bendfunction//defines"string"+%t
="stringT" functionx=%c_a_b(a,b)x=a+string(b)endfunction//defines %f+"
string" ="F string"
functionx=%b_a_c(a,b)x=string(a)+bendfunction//defines ["hi" %t] =
["hi""T"]
functionx=%c_c_b(a,b)x=[astring(b)]endfunctionfunctionx=%b_c_c(a,b)x=[string(a)b]endfunction//defines
["hi" 5] = ["hi""5"]
functionx=%c_c_s(a,b)x=[astringE(b)]endfunctionfunctionx=%s_c_c(a,b)x=[stringE(a)b]endfunctionfunctionx=%c_f_s(a,b)x=[a;stringE(b)]endfunctionfunctionx=%s_f_c(a,b)x=[stringE(a);b]endfunction
Exported from Notepad++
/_NB_/ : how to initialize a matrix of string ? equivalent to "zeros(n)" ....
M = emptystr(3,2)
(by the way, zeros(n) creates a 1x1 matrix)
Thanks
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
--
Adrien Vogt-Schilb (Cired)
+33 (0) 1 43 94 73 83
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users