Proper File Handling in Matlab
Ältere Kommentare anzeigen
Hello Community,
I have created a complex set of GUIs that i use in the process of image analysis. Once I have used the tools to identify all the objects of interest in am image I save a matlab work space that contains within it a single variable that is a cell. Once I have done this for several images I wish to apply an algorithm which processes my data in batches. To do this I use the following code
%Selects all the files I with to work on and makes sure they are on the path
[fNames,PathName,~] = uigetfile('*.mat','MultiSelect','on');
addpath(PathName)
% Create a loop to apply the process to the file
for p=1:numel(fNames)
data=importdata([PathName,fNames{p}]);
%Apply Calculations saving the result in the data variable
tempFNAME=regexp(fNames{p},'\.','split');
save([SequenceDirectory,['\',tempFNAME{1},'_Caluculation.mat']],'data', '-v7.3')
clear data
end
This Process works well for as it does update the files and then save them so that I can open them later. However, I am having an issue where the files I have opened using this method as well as other files in the directory are get corrupted periodically. As I see it this could be an issue with my Hard Drive (its a SSD drive) or an issue with poor file handling leading to corruption of files.
My questions is this. How should I be opening and closing file handles to ensure the issues with data corruption are from a faulty drive and not my code? This may be a simple question but I am very much self taught in matlab and more of a biologist than computer scientist. Thanks for the Help
Regards,
Dan
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Import and Export finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!