Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Import Data using function

1 Ansicht (letzte 30 Tage)
Arvind Mahendran
Arvind Mahendran am 26 Mär. 2012
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I want to import 2 .DAT into my code using a function When using the import wizard i make it a point to neglect the textdata here is a small exert of the files
XAXIS ZAXIS Eintensity Hintensity Sintensity
-1.50000000 -1.50000000 1.04858450 0.88251762 0.96197417
-1.47000000 -1.50000000 1.05946741 0.90707882 0.98031650
-1.44000000 -1.50000000 0.98867187 1.03632028 1.01221574
-1.41000000 -1.50000000 0.98153259 1.06804583 1.02387586
-1.38000000 -1.50000000 0.96053362 1.05617225 1.00721842
-1.35000000 -1.50000000 0.99755509 1.01285533 1.00517610
-1.32000000 -1.50000000 0.99126668 1.04608833 1.01830865
-1.29000000 -1.50000000 1.02578740 0.98220775 1.00376109
-1.26000000 -1.50000000 1.08350872 0.85828860 0.96434599
-1.23000000 -1.50000000 1.09498790 0.88392760 0.98381402
i've tried to use the load function but the text at the top of the file creates an error. I cannot change the file as it is hardcoded into another software.
Any ideas?

Antworten (2)

Geoff
Geoff am 26 Mär. 2012
A = textread( 'mydata.dat', '', 'headerlines', 1 );

per isakson
per isakson am 26 Mär. 2012
Why not use the wizard and just ignore or delete textdata?
Here is an alternative to textread. Doc says: "textread will be removed in a future version. Use textscan instead."
I copied your sample to 'h:\m\cssm\cssm.dat'.
I prefer to give Headerlines the value 2. In case I redefine Whitespace. That is if there is an empty line between the header and the data.
fid = fopen( 'h:\m\cssm\cssm.dat', 'r' );
cac = textscan( fid, '', 'Headerlines', 2 );
fclose( fid );

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by