[Scilab-users] Read matrix from text file

Frieder Nikolaisen Frieder.Nikolaisen at student.hs-rm.de
Tue Mar 21 09:10:15 CET 2017


 

Thanks alot. It also works with file and read for me. But I still
don't know how to handle a string header: read: Wrong number of output
argument(s): 0 expected.

Koeffizienten_DM=file("open",
"C:Usersf.nikolaisenDocumentsBachelorarbeitSimulationKoeffizienten_DM_Matrix.txt",
"old")

E=read(Koeffizienten_DM,-1,4)

disp(E)

file('close',Koeffizienten_DM);

Could
I still choose the document as a user? And having there not an abselout
path, but the current directory opened. 

Sorry for this beginners
questions, its really hard to get this details with the Scilab help.


Greetings 

Frieder 

Am 2017-03-20 17:53, schrieb Tim Wescott: 

> On
Mon, 2017-03-20 at 17:26 +0100, Frieder Nikolaisen wrote:
> 
>> Hello, I
do try to read a matrix of floating point numbers from a text file. I
want to have floating point numbers in Sciliab. (I used before mgetl
which return strings). I have attached the example text file and scilab
file. The error it says is: read: Wrong number of output argument(s): 0
expected. Thank you. Greetings Frieder My code: Koeffizienten_Pfad =
uigetfile(["*.txt"],'',"Wählen Sie die Datei Koeffizienten");
Koeffizienten = mopen(Koeffizienten_Pfad) B = read(Koeffizienten,-1,4)
disp(B) mclose('all')
> 
> Scilab has multiple contradictory ways of
managing files. It appears
> that "mopen" is not compatible with "read".
To use read:
> 
> -->file("open", "bob.txt", "old");
> 
> -->read(bob,
-1, 4)
> ans =
> 
> 1. 2. 3. 4. 
> 5. 6. 7. - 8. 
> 
> -->file("close",
bob);
> 
> However, if you can trust that your file will always be in a
tidy
> format, you can use fscanfMat:
> 
> -->fscanfMat("bob.txt")
> ans
=
> 
> 1. 2. 3. 4. 
> 5. 6. 7. - 8.
> 
> (You can also use mopen and
mfscanf -- the "file" stuff is "Fortran-
> like", the "mopen" stuff is
"C-like", and fscanfMat is just convenient.
> I tend to use the C-like
stuff because most of my "real" programming
> work is done in C, so I'm
familiar with it. Pick your poison.)

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170321/e5b5a7b0/attachment.htm>


More information about the users mailing list