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!