Loading txt data using textscan
古いコメントを表示
Hi i'm trying to load some data from a text file from line 137 to 147. the data contains the year and the anomalies values. I tried using this codes but i keep getting these errors:
Index exceeds matrix dimensions.
Error in anomalies (line 6)
A = cell2mat(data_anomalies(137:147,2:13)); % raw (not interpolated/filled)
& my data_anomalies contains the value "14x1 double".
% Load the data
fileID = fopen('../pdata/GISS_NH_temp_anomalies.txt','r','n');
data_anomalies = textscan(fileID,'%f %f %f %f %f %f %f %f %f %f %f %f %f','Delimiter','/t','HeaderLines',136);
fclose(fileID);
% Extract the specific data required
A = cell2mat(data_anomalies(137:147,2:13)); % raw (not interpolated/filled)
% Datenum: point in time as the number of days from January 0, 0000
Date = datenum(cell2mat(data_anomalies(:,1)));
3 件のコメント
per isakson
2018 年 5 月 13 日
Looks like your format string doesn't match the file or the other way round. Please attach the text file.
Walter Roberson
2018 年 5 月 13 日
Try delimiter \t instead of /t
FMR
2018 年 5 月 13 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Time Series Events についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!