Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - 日本語 - Русский

Please note that the recommended version of Scilab is 6.0.1. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Xcos > palettes > Sinks palette > WRITEC_f

WRITEC_f

Write to C binary file

Block Screenshot

Description

This block allows to user to write data in a C binary file with the name defined by the string Output File Name. The file is a sequence of records. Each record has the length fixed by the parameter Input Size and the structure shown below:

where the block inputs are numbered from top to bottom.

The record fields must contains data of the same type defined by the parameter Output Format.

Each event on the activation input of the bloc writes a record in the file. Note that contrary in WFILE_f, the event dates are not recorded.

Data types

  • Input: a scalar or a column vector of size Input Size.

Dialog box

  • Input Size

    A scalar, the size of the input column vector.

    Properties : Type 'vec' of size 1

  • Output File Name

    A character string defining the path and the file name of the file to be write. The block support file name expansion and you can use environment variables like HOME in the path, by example "HOME/my_data/foo.data". Without file path, the file is wrote in the directory defined by the PWD variable.

    The file path must exist, otherwise you will be prompted by an error message.

    Properties : Type 'str' of size 1

  • Output Format

    A character string defining the format to use. The following string "l", "i", "s", "ul", "ui", "us", "d", "f", "c", "uc" are used respectively to write int32, int16, int8, uint32, uint16, uint8, double, float, char or unsigned char data type.

    You must use the same format when you read the file with READC_f.

    Properties : Type 'str' of size 1

  • Buffer size

    To improve efficiency it is possible to buffer the input data. Data writing on the file is only done when the buffer is full.

    Properties : Type 'vec' of size 1

  • Swap Mode (0:No, 1:Yes)

    Endian IEEE format

    • 0: automatic bytes swap is disabled.

    • 1: the file is supposed to be coded in "little endian IEEE format" and data are swapped if necessary to match the IEEE format of the processor.

    Properties : Type 'vec' of size 1

Default properties

  • always active: no

  • direct-feedthrough: yes

  • zero-crossing: no

  • mode: no

  • regular inputs:

    - port 1 : size [1,1] / type 1

  • number/sizes of activation inputs: 1

  • number/sizes of activation outputs: 0

  • continuous-time state: no

  • discrete-time state: yes

  • object discrete-time state: no

  • name of computational function: writec

Example

In this example the block is used to record the output of the sine wave generator. To record at the same time, the time events, we use a TIME_f block and a multiplexer to form the input vector of the WRITEC_f block which record the data in the file "TMPDIR/writec_f.data". Then you can read these data with the block READC_f. Open this example in Xcos .

Computational function

  • SCI/modules/scicos_blocks/src/c/writec.c (Type 2)

See also

  • READC_f — Read binary data
  • RFILE_f — Read from input file
  • WFILE_f — Write to output file. This function is obsolete.

Comments

Author : Chamfrault Marthe posted the 25/02/2013 12:16
Hello,
I'm searching for help with the Wfilec_f block. I would just like to use the output of my xcos-file in Excel. But the file generated by the Writec_f-block can't be read by excel or Windows-Editor (binary isn't read).
Would be very nice if someone can help me/give me a link with explanations.
Have a nice day,
Marthe
Reply to this comment
Please login to comment this page

Author : Chamfrault Marthe posted the 26/02/2013 08:31
I found a solution, it may be useful for somebody...
You need to write a short Scilab Script like this:

fdT=mopen('binary_file', 'rb');
binary_data=mget(1000, 'f', fdT); //change the number with the size of your data (2columns of 500 data-->1000)
fdT2=mopen('text_file.txt', 'wt');
for i=1:500,
mfprintf(fdT2,'%f %f\n',binary_data(2*i-1),binary_data(2*i));
end
mclose('all');

You will have the "text_file.txt" in your PWD-Folder and can use it with Excel.
Reply to this comment
Please login to comment this page

Author : Daniel Llano posted the 11/01/2016 20:49
In windows 10, using Scilab 5.5.2 I have a problem with these block, when I run your example I get the following error:

Scilab has found a critical error (EXCEPTION_ACCESS_VIOLATION)
with "scicosim" function.
Save your data and restart Scilab.

Even changing the path, I sure I'm in a writable location and it creates the file but empty.

Any clue about what is the problem?
Reply to this comment
Please login to comment this page


Add a comment:
Please login to comment this page.

Report an issue
<< WRITEAU_f Sinks palette Sources palette >>

Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Oct 01 17:34:56 CEST 2012