<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#330000">
On 20/07/2011 14:59, Adrien Vogt-Schilb wrote:
<blockquote cite="mid:4E26D14A.6070505@centre-cired.fr" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 20/07/2011 14:25, computidoo wrote:
<blockquote cite="mid:1311164701390-3185296.post@n3.nabble.com"
type="cite">
<pre wrap="">hello,
and i want to have in the ascii
a
======
1 1
1 1
======
what is the line that i have to write
best regard
</pre>
</blockquote>
<blockquote cite="mid:1311164701390-3185296.post@n3.nabble.com"
type="cite">
<pre wrap="">computidoo</pre>
</blockquote>
<br>
Hi<br>
</blockquote>
the precedent mail was poorly rendered, here it goes again without
fancy formating : <br>
<br>
//I would recommend to drop the "===", so the file is much easier to
parse<br>
<br>
function mybetterexport(varname)<br>
matval = evstr(varname);<br>
[n m] = size(matval);<br>
<br>
output = emptystr(n+1,m); //n+3 if you <br>
// output = emptystr(n+3,m); //if you really need the =====<br>
output(1,1) = varname;<br>
output(2:$,:) = string(matval);<br>
// output(3:$-1,:) = string(matval);<br>
// output([2 $],:) = "="<br>
<br>
write_csv(output,varname+".tsv") //you should be able to open
the tsv file with excel, in a very convinient way. you can use any
notepad too<br>
endfunction<br>
<br>
foo=rand(3,5);<br>
<br>
//two ways to use the functions<br>
mybetterexport foo<br>
mybetterexport("foo");<br>
<br>
//lets read the generated file<br>
[ val txt] = fscanfMat ("foo.tsv") //this function will parse
"foo.tsv" very very quickly<br>
<br>
//which allows : <br>
function mybetterimport(varname)<br>
[ val txt] = fscanfMat (varname+".tsv") //very useful ! <br>
<br>
if varname~=stripblanks(txt,%t) //paranoid check, you could
drop this an rely on the filename<br>
error("file corrupted")<br>
end<br>
disp(varname+" will be loaded to scilab") <br>
execstr("["+varname+"]=return(val)") //if you want to
understand this wizzard stuff, try "help execstr" and "help return",
and also
<a class="moz-txt-link-freetext" href="http://wiki.scilab.org/howto/global%20and%20local%20variables">http://wiki.scilab.org/howto/global%20and%20local%20variables</a><br>
endfunction<br>
<br>
clear foo //forgets foo<br>
mybetterimport foo<br>
mybetterimport("foo") <br>
foo //this is total magic<br>
<br>
<br>
<br>
<br>
<div class="moz-signature">-- <br>
<p style="color: teal; font-size: 12pt;"><b>Adrien Vogt-Schilb</b><br>
Research Fellow<br>
<a class="moz-txt-link-abbreviated" href="mailto:vogt@centre-cired.fr">vogt@centre-cired.fr</a><br>
Tel: (+33) 1 43 94 73 96<br>
Fax: (+33) 1 43 94 73 70<br>
</p>
<table style="border: medium none;">
<tbody>
<tr>
<td style="padding: 0pt;">
<p><img src="cid:part1.08080802.01080203@centre-cired.fr"
alt="CIRED" width="54"></p>
</td>
<td style="padding: 0pt 7pt;" valign="middle">
<p style="font-size: 10pt; color: teal;">45 bis, Av de la
Belle Gabrielle<br>
F-94736 Nogent-sur-Marne<br>
<a href="http://www.centre-cired.fr/" style="color:
teal;">http://www.centre-cired.fr/</a><br>
</p>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>