how to write a matrix operation for subtract
조회 수: 1 (최근 30일)
이전 댓글 표시
I have sets of files (but no file extension), like follows (sample has been attached to the thread).
eachfile is 200x200 matrix
depth, depth_00001, depth_00002, depth_00003, depth_00004, depth_00005, depth_00006, depth_00007, depth_00008, depth_00009, depth_00010
I want to write a function to subtract 'depth' file from every other files of depth_00001 to depth_00010 and save the output as slide_00001, slide_00002, etc.
i want to do this at a single program at one time.
Please be kind enough to help anyone knows.
Previously I put the same question and I recived answers but not feasible.
댓글 수: 0
채택된 답변
Walter Roberson
2024년 1월 23일
M = readmatrix('depth');
files = dir('depth_*');
for K = 1 : numel(files)
infile = files(K).name;
outfile = regexprep(infile, 'depth_', 'slide_');
M_in = readmatrix(infile);
difference = M_in - M;
writematrix(difference, outfile);
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!