High Memory Usage with function files

I have created a code that do some calculations.
this code consists of a Script file and four functions.
Fun1, Fun 2 and Fun 3 output are one image for each. to create this image every function read around 100 images
these three images are used as input for Fun 4. Fun 4 read 500 image and do some calculations.
when i run this code, the memory usage in the first 3 functions is nearly 20% but when fun4 is being executed, the ram increases to 96%.
I tried to use clearvars at the end of each function but nothing happen.
i tried to use "pack" at the begining of the script file but nothing happen
Please note that i run this code before using script files instead of functions and the memory usage was much less.
I have to use the function files as there are more folders which require to run the code a lot and using function will let me to run it only one time.
So, what should i do to reduce this memory usage?

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Convert Image Type 的更多信息

产品

版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by