我需要一些帮助在MATLAB中读取.dat文件(作为数组)。
文件的内容(如果我用记事本打开它)就像这样
public class NoLoopSort {
static int[] values = new int[] { 4, 2, 5, 1, 3 };
public static void main(String[] args) {
printLower(0, values.length - 1);
printLower(0, values.length - 1);
printLower(0, values.length - 1);
printLower(0, values.length - 1);
printLower(0, values.length - 1);
}
private static void printLower(int start, int end) {
if (start == end) {
// this is currently the lowest number in array, print it.
System.out.println(values[start]);
// make current index biggest possible
values[start] = Integer.MAX_VALUE;
} else {
if (values[start] < values[end]) {
printLower(start, end - 1);
} else if (values[start] >= values[end]) {
printLower(start + 1, end);
}
}
}
}
下面还有更多的线路,我真的不需要前几个线路。我只需要有数字 在他们的牢房里。当我使用Excel或Libre Office打开文件时,它将打开,不带逗号或引号等。
阅读文件的最佳方法是什么?我找到了一些方法,但我遗漏了一些让它正常工作的东西:
"TOA5","CR800Series","CR800","36460","CR800.Std.28","CPU:HAC.CR8","48946","HAC_Meteo_Data_05"
"TIMESTAMP","RECORD","Anonymous1","Anonymous2","Tair_Avg","Tair_Std","RH_Avg","RH_Std","SolRad_Avg","SolRad_Std","AcVirTemp_Avg","AcVirTemp_Std","WV_XYZ_Avg","WV_XYZ_Std","WD_Elev_Avg","WD_Elev_Std","WD_Azim_Avg","WD_Azim_Std","WV_Azim_Avg","WV_Azim_Std","WV_X_Avg","WV_X_Std","WV_Y_Avg","WV_Y_Std","WV_Z_Avg","WV_Z_Std","PTemp","batt_volt_Min"
"TS","RN","","","deg_Celsiou","deg_Celsiou","%","%","W/m2","W/m2","","","","","","","","","","","","","","","","","",""
"","","Smp","Smp","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Avg","Std","Smp","Min"
"2016-05-21 04:05:00",9825,105,711,3.93,0.014,100,0,"NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN",23.01,13.87
"2016-05-21 04:10:00",9826,105,711,3.934,0.018,100,0,"NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN","NAN",23.01,13.87
我收到此错误:
f= fopen('x.dat');
data=fread(f);
fclose(f);`
y = importdata('x.csv') %I converted my .dat to a .csv and that worked well, but I really need it to read from the .dat file
fIDF=fopen(nameFile);
NephtDataAr0= textscan(fIDF, '%s %f %f %f %f %f %f %f %f %f %f %f %s %s','Delimiter',',','CommentStyle','[');
fclose(fIDF);
%Someone that has written a program to read some similar data from a .txt file, used the line above. Could that be of any use?
filename = 'csvlist.dat';
M = csvread(filename)
答案 0 :(得分:0)