
matlab系统提示:计算机格式错误,这是为什么呢?
imageData = fread(fid, [imageSize(1) imageSize(2)], pixelType, byteOrder);,报错代码是这一行
clc;
clear;
folderPath = 'D:\2024\HG\0';
%%
fileList = dir(fullfile(folderPath, '*.raw'));
%%
numFiles = length(fileList);
disp(numFiles);
%%
% 图像尺寸和像素类型
imageSize = [2048 2048];
pixelType = 'uint16';
byteOrder = 'big-endian';
%%
% 初始化结果矩阵
resultMatrix = zeros(imageSize(1), imageSize(2), numFiles, pixelType);
%%
for i = 1:numFiles
% 使用 fullfile 来确保路径正确
imageFilePath = fullfile(folderPath, fileList(i).name);
% 打开文件
fid = fopen(imageFilePath, 'r');
% 读取数据
imageData = fread(fid, [imageSize(1) imageSize(2)], pixelType, byteOrder);
% 关闭文件
fclose(fid);
% 填充到 resultMatrix
resultMatrix(:,:,i) = imageData;
end