Save original data to a new matrix?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello! I have the following code:
[vars]= find(difference < center - marginOfError | difference > center + marginOfError);
cd('Threshold Tested Data');
saving = strcat(fractions(nn).name(1:end-4),'_and_Threshed.mat');
save(saving);
The current code runs fine. However,when the new matrix saves, it's just a series of ones. I would like it to save the exact cells from my variable 'difference' that exceed the margin set by 'center +/- marginOfError'.
Thanks!
0 comentarios
Respuestas (1)
Image Analyst
el 22 de Jul. de 2015
Try this:
% Find out what elements of "differences" we want to keep:
elementsToKeep = abs(difference - center) > marginOfError;
% Create a filename:
baseFileName = sprintf('%s_and_Threshed.mat', fractions(nn).name(1:end-4));
% Create a subfolder.
folder = fullfile(pwd, 'fractions(nn).name(1:end-4)');
if ~exist(folder, 'dir')
% Does not exist yet - need to create it.
mkdir(folder);
end
% Combine folder and baseFileName into one string.
fullFileName = fullfile(folder, baseFileName);
% cd('Threshold Tested Data'); % don't use cd!!!
% Save only the elements of "differences" that we want to keep into our mat file.
save(fullFileName, differences(elementsToKeep));
0 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!