我有一个文件在一个月内达到30个文件在一个月中。每个文件包含86400行,具有以下数据格式,如下所示: 小时最小秒值1值2值3 ..... 但是,该文件包含很多缺失的行。因此,通过使用interpolation.later检查每个文件 插入缺少的行变得单调乏味,我必须将一个文件追加到另一个文件以便为每个月创建一个大文件= 86400 * 30行)。谨建议我可以补偿时间和人力的任何代码。在matlab中处理数据
回答
要阅读所有的文件和堆栈数据,以形成B
, 可以用在文件名的循环:
for d = 1:30
filename = sprintf('file%d.txt', d);
A{ d } = load(filename);
% complete missing values in A{d} here, for example using interpMissingRows below
A{ d } = interpMissingRows(A{ d });
end
B = vertcat(A{:});
为了计算缺少项,您可以插值:
function interpData = interpMissingRows(data)
% compute seconds from 00:00:00 (assuming first entry is 0, 0, 0, val1 val2...
absSec = data(:,1:3) * [ 3600; 60; 1]; % matrix multiplication!
numValues = size(data,2) - 3; % number of colums to interpolate
totSec = 24*3600; % number of seconds in 24Hours
interpData = zeros(totSec, 3 + numValues); % pre-allocate
interpData(:,1) = floor((0:totSec-1)'/3600); % hours
interpData(:,2) = floor(((0:totSec-1)' - interpData(:,1)*3600)/60); % minutes
interpData(:,3) = mod( (0:totSec-1)', 60); % seconds
interpData(:, 4:end) = interp1(absSec, data(:, 4:end), (0:totSec-1)', 'linear','extrap');
@Shai ...我已经成功地运行了1或2个文件的代码。但是我仍然发现在matlab中有严重的错误评论as.Please Kindly rectify它..... ???错误使用==> interp1在259 X的值应该是不同的。 (0,totSec-1)','线性','extrap')中的错误== ==> interpMissingRows 10 interpData(:, 4:end)= interp1(absSec,data(:, 4:end) ; 错误在==> catenation at 8 A {d} = interpMissingRows(A {d}); – Bunnies
@PrasantaChingtham看起来你的文件似乎有一个重复的行:这是具有相同小时,分钟,秒值的两个条目。 – Shai
@Shai ...我用独特的方法删除行中的重复... A {d} =唯一(A {d},'rows');它不起作用。任何替代方法都可以删除重复的行.. – Bunnies
- 1. 在MATLAB中删除/处理数据
- 2. 在Matlab中处理二进制数据
- 3. Matlab数组处理
- 4. 在Matlab中的数字信号处理
- 5. 在MATLAB中用vpa处理大数字
- 6. 同时在matlab中处理多个数据
- 7. 在Matlab中对数据库输入进行消毒处理?
- 8. Matlab的 - 处理
- 9. 在Matlab中使用textscan处理数据格式不正确的数据
- 10. MATLAB vs Simulink在数字图像处理?
- 11. matlab中的图像处理
- 12. Matlab中的鼠标处理
- 13. MATLAB中的阈值处理
- 14. 功能处理在MATLAB
- 15. 嵌套循环用于MATLAB中的列数据处理
- 16. 在Matlab中处理多个图像
- 17. 在MATLAB中处理多个图
- 18. 在Matlab中使用DLL处理DLL
- 19. 在matlab中合并和处理文件
- 20. 在matlab中处理字符串
- 21. 如何在Matlab中处理MySQL关机?
- 22. 在matlab中处理结构GUI
- 23. 图像处理在MATLAB中的错误
- 24. 在Matlab中实时摄像头处理
- 25. MATLAB(图像处理)
- 26. Matlab处理边缘
- 27. Matlab'图像处理'
- 28. Matlab图像处理
- 29. MATLAB - 视频处理
- 30. 在二维数组中处理数据
你有什么尝试? –
已手动检查每个文件以确保不应有缺失的行。然后,我运行这个程序A1 = load('file1.txt'); ------------------ ----------------- A30 = load('file30.txt'); B = [A1; A2 ....... A30]。 B包含86400 * 30行.......... – Bunnies