Borrar filtros
Borrar filtros

how to write a matrix operation for subtract

1 visualización (últimos 30 días)
幸一
幸一 el 23 de En. de 2024
Comentada: 幸一 el 23 de En. de 2024
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de En. de 2024
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

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by