Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I get MATLAB to output a part of a dat file the proper way?

1 回表示 (過去 30 日間)
Ruten9
Ruten9 2015 年 10 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want my output to come out exactly as shown in the attached picture. How can I do this?
This is my code:
clear all;
clc;
tempdata = fopen('rec0506a.dat','r') ;
fgetl(tempdata);
fgetl(tempdata);
T = fscanf(tempdata, '%*f %f %f %f \n')
fclose(tempdata);
  2 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 10 月 25 日
Ruten9 - you did not attach a picture. Please make sure that you press the Attach File button once you have chosen your file. Also, please describe the format of your text file. Does each row have four floating point numbers that are delimited by a space character? Are the first two lines header rows that you wish to exclude (which explains the two calls to fgetl)?
Ruten9
Ruten9 2015 年 10 月 25 日
I've attached the file now.

回答 (1 件)

Geoff Hayes
Geoff Hayes 2015 年 10 月 25 日
編集済み: Geoff Hayes 2015 年 10 月 25 日
Ruten9 - why not try using importdata where you can specify the delimiter and the number of header rows (to ignore). For example, try using the following
A = importdata('rec0506a.dat', ' ', 2);
where we assume that the column separator is the space character and that there are there are two header lines. (This assumes that your dat file is ASCII.)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by