|
|
how to use textscan with gnu octave 3.6.2 |
|
Brico |
Forum-Newbie
|
|
Beiträge: 6
|
|
|
|
Anmeldedatum: 10.01.13
|
|
|
|
Wohnort: ---
|
|
|
|
Version: ---
|
|
|
|
|
|
Verfasst am: 10.01.2013, 18:02
Titel: how to use textscan with gnu octave 3.6.2
|
|
|
|
|
how to use textscan with octave
hello
i am using gnu octave 3.6.2 since 10 days and i ned to read all the rows of a (.txt)file with textscan.
the file i want to read looks like
"
4 = Interface Serial-No :
5 = Calibrated by :
6 = Radiation Quality :
7 = Measuring Quantity :
[Kanal_Info]
;Kanal-Nr. = Status(Aktiv/Inaktiv);A/D-Kanal(1-4);IF-KanalNr;X_0;Y_0;K-Faktor;"Bemerkung"
0 = Aktiv;1;0;-126;0;1.021;""
1 = Aktiv;1;1;-123;0;1.021;""
2 = Aktiv;1;2;-120;0;1.021;""
3 = Aktiv;1;3;-117;0;1.021;""
4 = Aktiv;1;4;-114;0;1.021;""
5 = Aktiv;1;5;-111;0;1.021;""
6 = Aktiv;1;6;-108;0;1.021;""
7 = Aktiv;1;7;-105;0;1.021;""
8 = Aktiv;1;8;-102;0;1.021;""
9 = Aktiv;1;9;-99;0;1.021;""
10 = Aktiv;1;10;-96;0;1.021;""
...
and the code i am using is the following.
"
..
Wenn i start this code on the comand window , it returns somethings else. I did a sreenshot of the
result and you can find it as image_attachment.
please can any one help me ?
i have ones used this code in Matlab and it has function.
thanks for your Help
Brico
Beschreibung: |
|
Download |
Dateiname: |
screenshot_octave.jpg |
Dateigröße: |
39.7 KB |
Heruntergeladen: |
2015 mal |
|
|
|
|
|
markuman |
Forum-Guru
|
|
Beiträge: 320
|
|
|
|
Anmeldedatum: 14.12.12
|
|
|
|
Wohnort: ---
|
|
|
|
Version: 2013a/2013b, Octave 3.6.4, 3.7.7
|
|
|
|
|
|
Verfasst am: 10.01.2013, 18:23
Titel:
|
|
i guess = is a string too.
try
but then i guess your b{numbering} doesn't match anymore.
_________________
DIY OR DIE
entropie=char(floor(94*rand(1, round(100.*rand)) + 32))
https://github.com/markuman
|
|
|
markuman |
Forum-Guru
|
|
Beiträge: 320
|
|
|
|
Anmeldedatum: 14.12.12
|
|
|
|
Wohnort: ---
|
|
|
|
Version: 2013a/2013b, Octave 3.6.4, 3.7.7
|
|
|
|
|
|
Verfasst am: 10.01.2013, 18:30
Titel:
|
|
if your file looks like that:
.... 8 lines before your values began
try with this lines function that
_________________
DIY OR DIE
entropie=char(floor(94*rand(1, round(100.*rand)) + 32))
https://github.com/markuman
|
|
|
Brico |
Themenstarter
Forum-Newbie
|
|
Beiträge: 6
|
|
|
|
Anmeldedatum: 10.01.13
|
|
|
|
Wohnort: ---
|
|
|
|
Version: ---
|
|
|
|
|
|
Verfasst am: 10.01.2013, 19:31
Titel: how to use textscan with gnu octave 3.6.2
|
|
hello,
thanks for your fast response but i do not really understand your code
please can you explain to me, what 'dlmread ' does here? and were can i insert it in my code?
i just read the 'Help dlmread ' but i could not understand what you did.
is 5 the number of colum?
do you mean i can use the ' lines function' instead of 'fgetl'?
excuse me if my question are not clear but like i just said i am begenning with Octave and i am just trying to understand
thanks for your help
brico
|
|
|
markuman |
Forum-Guru
|
|
Beiträge: 320
|
|
|
|
Anmeldedatum: 14.12.12
|
|
|
|
Wohnort: ---
|
|
|
|
Version: 2013a/2013b, Octave 3.6.4, 3.7.7
|
|
|
|
|
|
Verfasst am: 10.01.2013, 19:55
Titel:
|
|
|
|
|
The 8 is skipping the first 8 lines. That's what you're doing with your while strgcmp..
The 1 skipp column 1. If you realy need it, creat it like test=[0:lines('yourfile')]';
The following two numbers define the range to read (calculated starts at your skipped rows and columns (the first two option nr.)) . Again, first row, and second column.
You have to save my lines.m function in the same folder. It just counts the lines of a file (so it reply a numbr. and usualy you don't know exactly how many lines/measurements you've got in a file it did the job). You can say, it set the column range to the end of the file.
and the range of column to 5, because the last column "" you don't need too i guess.
but be aware, this dlmread command won't work in matlab when you try to skip non numerical expressions like everywhere in your file
it can replace your complete fopen to fclose part, if this is enough for you.
you only have to customize your variablenames (x_array_in_mm, y_array_in_mm ....) to the coloumns of the dlmread output.
as i see, you are asking on the octave mailing lists too. There isn't just one way of doing it. It was just a suggestion.
i hope you can follow my worse english.
take care, markus
_________________
DIY OR DIE
entropie=char(floor(94*rand(1, round(100.*rand)) + 32))
https://github.com/markuman
|
|
|
Brico |
Themenstarter
Forum-Newbie
|
|
Beiträge: 6
|
|
|
|
Anmeldedatum: 10.01.13
|
|
|
|
Wohnort: ---
|
|
|
|
Version: ---
|
|
|
|
|
|
Verfasst am: 11.01.2013, 11:07
Titel:
|
|
|
|
|
hallo Marcus
Thank you for your reply.
Is there another way of doing this without the lines? The reason why I say that is the following:
The data I am trying to read is a very long file it has more than 50 line before the value begins (thats the reason why I use strcmp). The values go from 0 till 600. You can fine an example as file-attachment. ('neue Textdokument.txt')
I need the 5th and the 6th Colum (my x- and y-coordinate) of this file to do a bilinear interpolation and i am supposed to write my results in a (.txt) file.
i do it like
You can also find an example of my results as file-attachment.
As you will see my must have this specific format:
That means I need to read all everything on this file because i will need them later to write my result-file.txt.
I will be very grateful if you can show me how to solve this with dlmread or everything else.... since texscan doesnt function well
i can send you my interpolation code if you are interested in it.
Sorry for the long message.
vielen Dank!
brice
Beschreibung: |
|
Download |
Dateiname: |
Neu Textdokument.txt |
Dateigröße: |
31.26 KB |
Heruntergeladen: |
1481 mal |
Beschreibung: |
this is the data were i getv my coordinates. (modified) |
|
Download |
Dateiname: |
Neu Textdokument (2).txt |
Dateigröße: |
3.8 KB |
Heruntergeladen: |
1305 mal |
|
|
|
markuman |
Forum-Guru
|
|
Beiträge: 320
|
|
|
|
Anmeldedatum: 14.12.12
|
|
|
|
Wohnort: ---
|
|
|
|
Version: 2013a/2013b, Octave 3.6.4, 3.7.7
|
|
|
|
|
|
Verfasst am: 11.01.2013, 17:44
Titel:
|
|
Brico hat Folgendes geschrieben: |
The data I am trying to read is a very long file
|
That's exactly for what lines() is made for
Brico hat Folgendes geschrieben: |
it has more than 50 line before the value begins (thats the reason why I use strcmp).
|
so just pimp the lines function, that it will give you the line for start reading (your while loop), and the end of the file, where it should stop reading.
build it like [from, to]=yourasskickingfunction('yourchaoticfile');
And than read it with data=dlmread('yourchaoticfile',' ',[from,1,5,to]);
Wir können sonst auch auf Deutsch weiterreden wenn es keinen hier verstört
Weil so ganz erschließt sich mir dein problem nicht, weil der dlmread befehl in verbindung mit der lines funktion doch alle Daten einliest.
_________________
DIY OR DIE
entropie=char(floor(94*rand(1, round(100.*rand)) + 32))
https://github.com/markuman
|
|
|
markuman |
Forum-Guru
|
|
Beiträge: 320
|
|
|
|
Anmeldedatum: 14.12.12
|
|
|
|
Wohnort: ---
|
|
|
|
Version: 2013a/2013b, Octave 3.6.4, 3.7.7
|
|
|
|
|
|
Verfasst am: 11.01.2013, 18:20
Titel:
|
|
Okey, in der Theorie nimmst du diese Funktion
Du verwendest sie so:
Allerdings fängt er zu spät an zu lesen, was vermutlich daran liegt, dass dlmread eine Leerzeile nicht als Zeile betrachtet.
Vielleicht sieht aber unter Windows die Datei nicht so Kaputt aus http://paste.osuv.de/index.php/epE/
Und wenn doch, musst du halt ein Korrekturschlag für den from Wert machen.
Oder wir reden immer noch aneinander vorbei
_________________
DIY OR DIE
entropie=char(floor(94*rand(1, round(100.*rand)) + 32))
https://github.com/markuman
|
|
|
Brico |
Themenstarter
Forum-Newbie
|
|
Beiträge: 6
|
|
|
|
Anmeldedatum: 10.01.13
|
|
|
|
Wohnort: ---
|
|
|
|
Version: ---
|
|
|
|
|
|
Verfasst am: 13.01.2013, 17:02
Titel:
|
|
hi marcus
i've tried your example and it functions thanks again.
someone in the Octave-group also show me how i can do this with textscan:
in case you are intrested in it
Know i need this result to do a bilinear interpolation. The code i wrote is the following
Octave should do a bilinear interpolation just when the canal is 'Aktiv' . but i think the command strcmp doesn't function this way. on the command-window i get just "-2 " everywhere. When i write the code this way,
the command -window gives me the right results.
Please do you have an idea how i can use strcmp in this case?
This is the complete code if you need it
ich würde so gerne auf Deutsch weiterschreiben aber ich glaube Englisch zu üben ist auch eine gute sache
thanks for your Help
brice
Beschreibung: |
|
Download |
Dateiname: |
Interpolate5.m |
Dateigröße: |
4.38 KB |
Heruntergeladen: |
1245 mal |
|
|
|
|
|
Einstellungen und Berechtigungen
|
|
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
|
|
Impressum
| Nutzungsbedingungen
| Datenschutz
| FAQ
| RSS
Hosted by:
Copyright © 2007 - 2024
goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.
|
|