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.

采纳的回答

Walter Roberson
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 CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by