参考链接:
使用MATLAB遍历文件
strtrim用法
strsplit用法
cell单元数据使用{}文章来源地址https://www.toymoban.com/news/detail-611570.html
close all;
dir_path = 'C:/Users/';
fileFolder = ls(dir_path);
fileNum = length(fileFolder(:,1)) - 2;
for i = 3:(3+fileNum-1)
file_path = strcat(dir_path, strtrim(fileFolder(i,:)));
fid = fopen(file_path, 'rb');
s = strsplit(strtrim(fileFolder(i,:)),'_');
c1 = str2_double(s{length(s)-2});
c2 = str2_double(s{length(s)-3});
data_length = c1 * c2;
A = fread(fid, data_length);
[N, X] = hist(A, 256);
x = 1:1:256;
f = figure;
plot(x, N);
title(strtrim(fileFolder(i,:)),'Interpreter','none');
grid on;
save_path = strcat(dir_path, strtrim(fileFolder(i,:)),'.fig');
savefig(save_path);
fclose(fid);
hold on;
end
close all;
文章来源:https://www.toymoban.com/news/detail-611570.html
到了这里,关于Matlab遍历文件及直方图统计的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!