<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 * Copyright (C) 2010 - DIGITEO - Allan CORNET
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="fprintfMat" xml:lang="en">
    <refnamediv>
        <refname>fprintfMat</refname>
        <refpurpose>writes a matrix in a file</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>fprintfMat(file, M [,format,text])</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>file</term>
                <listitem>
                    <para>a string, the pathname of the file to be written</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>M</term>
                <listitem>
                    <para>a matrix of real numbers</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>format</term>
                <listitem>
                    <para>a character string giving the format. This is an optional
                        parameter, the default value is <literal>"%lf"</literal>.
                    </para>
                    <para>Supported format:
                        <literal>%[width].[precision]type</literal> or
                        <literal>%type</literal>, where:
                    </para>
                    <para>
                        <literal>width</literal>: an optional number that specifies the minimum number of characters output;
                    </para>
                    <para>
                        <literal>precision</literal>: an optional number that
                        specifies the maximum number of characters printed for all
                        or part of the output field, or the minimum number of
                        digits printed for integer values;
                    </para>
                    <para>
                        <literal>type</literal>: lf, lg, d, i, e, f, g (see <link
            linkend="scanf_conversion">scanf_conversion</link> for details).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>text</term>
                <listitem>
                    <para>
                        a row (column) vector of strings giving non numerical
                        comments stored at the beginning of the file.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            The <function>fprintfMat</function> function writes a matrix in a
            formatted file. Each row of the matrix give a line in the file. If
            <varname>text</varname> is given then the elements of
            <varname>text</varname> are inserted elementwise at the beginning of the
            file one element per line.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
n = 50;
a = rand(n, n, "u");
fprintfMat(TMPDIR + "/Mat", a, "%5.2f");
a1 = fscanfMat(TMPDIR + "/Mat");

// Lets we create a file Mat1 and insert a comment into it
some_comment = ["This is a comment","This the second line of the comment.","This is the third line of the comment."];
fprintfMat(TMPDIR + "/Mat1", a, "%5.2f",some_comment);
   ]]> </programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="scanf_conversion">scanf_conversion</link>
            </member>
            <member>
                <link linkend="mclose">mclose</link>
            </member>
            <member>
                <link linkend="meof">meof</link>
            </member>
            <member>
                <link linkend="mfprintf">mfprintf</link>
            </member>
            <member>
                <link linkend="mfscanf">mfscanf</link>
            </member>
            <member>
                <link linkend="fscanfMat">fscanfMat</link>
            </member>
            <member>
                <link linkend="mget">mget</link>
            </member>
            <member>
                <link linkend="mgetstr">mgetstr</link>
            </member>
            <member>
                <link linkend="mopen">mopen</link>
            </member>
            <member>
                <link linkend="mprintf">mprintf</link>
            </member>
            <member>
                <link linkend="mput">mput</link>
            </member>
            <member>
                <link linkend="mputstr">mputstr</link>
            </member>
            <member>
                <link linkend="mscanf">mscanf</link>
            </member>
            <member>
                <link linkend="mseek">mseek</link>
            </member>
            <member>
                <link linkend="mtell">mtell</link>
            </member>
            <member>
                <link linkend="mdelete">mdelete</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
