필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Import Data using function

조회 수: 1 (최근 30일)
Arvind Mahendran
Arvind Mahendran 2012년 3월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
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?

답변 (2개)

Geoff
Geoff 2012년 3월 26일
A = textread( 'mydata.dat', '', 'headerlines', 1 );

per isakson
per isakson 2012년 3월 26일
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 );

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by