Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

report with scilab

643 views
Skip to first unread message

Fabri

unread,
Nov 22, 2006, 11:01:27 AM11/22/06
to
Hello all, is there a way to make a report with scilab?
For example I'm able to create a plot and to produce a postscript file
with that plot, but I want also to print something else on the same
page where the plot is, for example other data or another plot.
I've red through the Help and in the "introduction to scilab" but found
nothing.
Any help would be appreciated.
Tnx
Fabri

Andreas Benkert

unread,
Nov 23, 2006, 4:28:16 AM11/23/06
to
Hello Fabri

I think Scilab is not really suited for the preparation of a report or
an article. But with the export possibilities (e.g. eps or xfig format)
and your standard tool for writing reports (latex would be preferable,
but word, open office, powerpoint or anything like that will also work)
it should not be a problem to create any kind of report needed.

It is also possible to do a automatisation if have to do the same kind
of report regularly. Scilab can produce the latex file, compile it and
create a pdf or ps file from the dvi file with just one mouse click (of
course after some programming...). If you're interested, I can send you
some examples.

Kind regards

Andreas Benkert

Frank Kulow

unread,
Nov 23, 2006, 5:04:58 AM11/23/06
to
Fabri schrieb:

Hallo NG,

is there a append-mode for grafiks, similar in matlabs print command?

Frank

Fabri

unread,
Nov 24, 2006, 9:29:00 AM11/24/06
to
Hello Andreas and thx for help, I'm really interested in viewing some
examples of yours.
I was also thinking on producing the plot as a Gif with scilab and then
build a document with that gif included, but I don't have ideas on how
to do it, especially because I've got to produce an automatic system
which reads data from a file or pipe and producing a report.
I can program some logic in c/gtk but don't know about how to produce
reports.
Thx for every example you send me
Bye

Andreas Benkert ha scritto:

Guillaume Dutilleux

unread,
Nov 24, 2006, 4:14:21 PM11/24/06
to
Hello,

Another solution is to have Scilab write a Docbook XML or SGML file
(http://www.docbook.org/whatis). From this, calling whether an XML
processor like xsltproc or a DSSSL engine like Openjade, you can
produce various output from the same source. The output formats are
HTML, RTF, TeX, LaTeX, PDF. The conversion to OpenOffice's ODF is an
ongoing project (search for docbook2odf with google). A major
difference between the LaTeX and the Docbook solution is that the
latter technology completely separates semantics and style.
I have used Docbook in connection with Scilab several times for writing
simulation or measurement reports and feel quite happy with it. I can
show you a few examples if you are interested, and share some lines of
code too.
Best regards,

G. Dutilleux

Fabri

unread,
Nov 27, 2006, 3:26:39 AM11/27/06
to
Hi, this solution also seems very interesting, I'm just studying a
little bit docbook, can you also send me some examples?
I have to read a txt file with a vector of data and produce a simple
report with the plot and some other dynamic data as the date and some
strings and send it to the printer.
Bye


Guillaume Dutilleux ha scritto:

Fabri

unread,
Nov 29, 2006, 4:46:39 AM11/29/06
to
Hi tnx for help but I can't find anything on how to write a Docbook XML
with silab, is that possible?

Guillaume Dutilleux ha scritto:

Guillaume Dutilleux

unread,
Nov 30, 2006, 4:17:34 PM11/30/06
to
Hello,

For producing a ps file the LaTeX way seems the most straightforward
solution. Here is an example. A standard LaTeX installation should do
the job whatever the platform. Mine is Mac OS X here. I run Scilab
3.1.1.

function s=latex_figure(figtitle,fname)
s='\begin{figure}{'+figtitle+'}';
s=[s;'\begin{center}'];
s=[s;'\epsfig{width=7cm,file='+fname+'}'];
s=[s;'\end{center}'];
s=[s;'\end{figure}'];
endfunction

texfname='sample.tex'
txt='This is a comment';
txt2='Another comment';
xset('window',0);
xbasc();
plot(rand(1,1000));
figname1='fig1.eps'
xs2eps(0,figname1);
xbasc();
plot(1:1000);
figname2='fig2.eps';
xs2eps(0,figname2);
tex_header=['\documentclass[a4]{article}';..
'\usepackage{epsfig}';..
'\pagestyle{empty}';..
'\begin{document}'];
tex_body=[txt;' ';' ';..
latex_figure('random data',figname1)
txt2;..
latex_figure('arithmetic series',figname2)];
tex_end='\end{document}';
s=[tex_header;tex_body;tex_end];
mputl(s,texfname);
[foo,name,ext]=fileparts(texfname);
host('latex '+name);
host('dvips -o '+name+'.ps '+name+'.dvi');

The Docbook way would be quite similar. The Docbook syntax is verbose
but I feel it is more systematic and easier to handle programmatically.
For Windows users, setting up a Docbook toolchain is not as hard as it
used to be. See wikipedia for a link to a self-contained Docbook
environment.
Best regards,

Guillaume Dutilleux

Guillaume Dutilleux

unread,
Dec 3, 2006, 2:52:42 AM12/3/06
to
Hello,
Here is a Docbook XML way to produce html, ps and,pdf reports from
within Scilab. You can see that the same source is used for all
outputs. Only the stylesheet changes.
Before copying and pasting you need a working Docbook toolchain
including
xsltproc
fop
the docbook XML stylesheets and Document Type Definition (DTD).
Also check that the paths in db_header and db_stylesheet correspond to
your configuration.
The script should work with docbook 4.x. Update the db_version variable
if necessary. As far as I know, Docbook 5.0 is still a work in progress
and stylesheets may not be available yet.

function s=tag(tagname,content)
topen='<'+tagname+'>';tclose='</'+tagname+'>';
if size(content,'*')==1 then
s=strcat([topen,content,tclose],'');
else
s=[topen;content;tclose];
end
endfunction

function s=db_figure(figtitle,fname,width)
s=tag('title',figtitle);
si=tag('imageobject','<imagedata width='"'+width+''"
fileref='"'+fname+''" format='"GIF'"/>');
si=[si;tag('textobject',tag('phrase','image description'))];
s=[s;tag('mediaobject',si)];
s=tag('figure',s);
endfunction

dbfname='sample.xml'


txt='This is a comment';
txt2='Another comment';
xset('window',0);
xbasc();
plot(rand(1,1000));

figname1='fig1.gif'
xs2gif(0,figname1);
xbasc();
plot(1:1000);
figname2='fig2.gif';
xs2gif(0,figname2);
db_version='4.2.0';
db_header=['<?xml version='"1.0'" encoding='"iso8859-1'" ?>';..
'<!DOCTYPE article PUBLIC '"-//OASIS//DTD DocBook XML
V'+db_version+'//EN'"..
'"/sw/share/xml/dtd/docbookx/'+db_version+'/docbookx.dtd'">'..
];
db_title=[tag('title','Sample docbook document');..
tag('author',tag('firstname','John')+tag('surname','Doe'))];
db_title=tag('articleinfo',db_title);
db_body=[tag('title','Chapter title');
tag('para',txt);..
db_figure('random data',figname1,'8cm');..
tag('para',txt2);..
db_figure('arithmetic series',figname2,'8cm')];
db_body=tag('section',db_body);
s=[db_header;tag('article',[db_title;db_body])];
mputl(s,dbfname);
[foo,name,ext]=fileparts(dbfname);
db_stylesheet='/sw/share/xml/xsl/docbook-xsl/fo/docbook.xsl';
host('xsltproc -o '+name+'.fo '+db_stylesheet+' '+dbfname);
host('fop '+name+'.fo '+name+'.pdf');
host('fop '+name+'.fo -ps '+name+'.ps');
db_stylesheet='/sw/share/xml/xsl/docbook-xsl/html/docbook.xsl';
host('xsltproc -o '+name+'.html '+db_stylesheet+' '+dbfname);

Hope this helps,

G. Dutilleux

0 new messages