Exporting data from Scilab to Excel

Sandrine Ellero -  
 daba -
Hello!

I can't properly export a matrix from Scilab to Excel.

I have a 12x90 matrix in Scilab and the export to Excel using the command
write('monfichier.xls',MatrixToExport,'(90(f10.2))')
gives me a matrix where the first 90 values of the first row of my matrix are all stored in the first cell of Excel.

I would like to have one value per cell actually. Does anyone know the proper Fortran format or another solution?

Thank you in advance,
Sandrine

8 réponses

bennn
 
fscanfmat and fprintfmat allow for directly exporting matrices to organized text files.
1
Clotaire
 
Simply put: xls_open and xls_read ----> all explained in the Scilab documentation
0
Armojax
 
Hello Sandrine,

I don't know Scilab at all. I suppose that this software gives you a file that, even if you call it "monfichier.xls", is likely to be in text format.

Try this:

Before you feed it to Excel, rename it and change its extension to ".txt".
Then, open it with Notepad or Wordpad. Normally, you should be able to see the plain text and check if the 90 values in a line are well separated by a delimiter, and what the separator is (comma, semicolon, tab, ...).

Next, open Excel. In Excel, choose "Open" and name your text file.
Excel will ask you questions about the formatting of your data.

It may be:
- that the problem is something else and I am completely wrong,
- that if your fields are decimal numbers, you may need to adjust your settings for the choice of decimal separator (dot or comma).

Good luck, and if that's not it, come back.

Armojax.
0
yassine
 
Hello everyone,

here it is, I'm starting with Scilab and I don't know the command that allows me to import an Excel file into Scilab to display the scatter points


thank you in advance

yassine.
0
souhir
 
Good evening,
I am also facing the same problem, I wonder if you managed to find a solution, I would be grateful
Thank you
Souhir
0
allergen
 
Hello,

Have you solved this issue?
0
zorba
 
Here might be the solution: https://digilander.libero.it/_ppricerca/index.html

If you test this solution, it would be nice to post your results in this forum. Thank you! ;)
0
Valeck
 
Hello everyone,

I'm also working on Scilab right now and I need to export my data to Excel. Here are the commands I typed:

input='your file location'; --> for example 'D:\Documents and Settings\...etc'
output='your file location';
flow='your file location';

fprintfMat('input.xls',B1); --> writes my matrix B1 into the file input
fprintfMat('output.xls',B2); --> writes my matrix B2 into the file output
fprintfMat('flow.xls',B3); --> writes my matrix B3 into the file flow

Right now, I have no problem since my matrices have only one row and several columns (depending on my data). And it works well.
I tried to solve your problem Sandrine by attempting to export a 30x30 matrix for example. And there yes there's an issue but not for all the data. The first column contains only one value per cell. The second unfortunately groups 4 columns. Then, it goes back to one value per cell.
I don't quite understand, I racked my brain over it earlier but now I can't anymore. I'll try again tomorrow ^^

However, I have another issue that you might be able to solve. When exporting the data for the flow, I only end up with zeros in Excel because it only exports 6 digits after the decimal. However, my flows are in 10^(-10).
Do you have a solution to increase the number of significant digits exported to Excel??

Thank you in advance, I'll repost if I find a solution to your problem

Valeck
0
philippe
 
Hello,

The best thing is to convert your data into string matrices (the string function in Scilab), a matrix that can have multiple columns. A basic example:

M=rand(100,2);//a matrix of reals
text=['x', 'y'; string(M)];//a matrix of strings
excel=[];//the content of the Excel file
n=size(text,1);//number of rows of text
for i=1:n
excel=[excel; strcat(text(i,:), ';')];//write in CSV format with ';' as separator
end
mputl(excel,'test.xls');//write to the file test.xls

it is in the for loop that I concatenate the elements of each row of my string matrix. The function strcat(matrix, separator) concatenates the elements of "matrix" by interspersing "separator" between them, which makes it easy to transform your matrices into CSV (comma-separated values) format that is perfectly readable by Excel (or Calc, by the way).

Philippe.
0
philippe
 
I forgot, to change the display format of real numbers you can use the format function. For example, format('v',20) will force the display of reals with 18 digits (well normally the machine zero is on the order of 10^(-16) so that's a bit excessive).

Philippe.
0
daba
 
Hello, I have the same issue actually. I need to import data into and then export a matrix so that I can use it properly... Does anyone have a solution to my problem?
0