I'm a bit stuck on how to remove all zeros from my matrix and using them to calculate basic statistical values such as the average. The zeros themselves represent blank data, therefore should be excluded from any form of calculations.
There isn't an exact pattern to where the zeros are located, so it makes it harder for me to work with it.
The following code is a simplified version of what I have thus far, however the values I get seem to be the exact same as if I did not include specific code targeting the zeros.
Data = load(fullfile(import(i).folder, import(i).name));
Data.importDataData.importData==0) = nan;
Mean(i,:) = mean(Data.importData, 'all', 'omitnan');
Stdev(i,:) = std(Data.importData, 0,'all', 'omitnan');
Median(i,:) = median(Data.importData, 'all', 'omitnan');
Mode(i,:) = halfrange(Data.importData, 'omitnan');
fileName(i,:) = convertCharsToStrings(strrep(import(i).name,'.mat','') )
tabData = table(fileName, Mean,Stdev,Median,Mode)
For reference, import is a workspace variable name that hold the matricies, which I am running through a loop. The import is being drawn from a seperate folder located outside of MATLAB.