https://github.com/simkind/Patch-clamp-analysis
Raw File
Tip revision: 1732ada9c8b7f1432fe3fd494fa00a27e29425ff authored by simkind on 16 March 2024, 19:13:22 UTC
Add files via upload
Tip revision: 1732ada
bracket2nan.m
% Converts empty brackets [] (no data) into NaN. Useful when writing
% results to excel 

function [Output] = bracket2nan(Results)

    for i = 1:length(Results)
        vars = fieldnames(Results(i));
        for j = 1:numel(vars)
            stuff = Results(i).(vars{j});
            thisField = vars{j};
            if isempty(stuff)
                replace = NaN;
                commandLine = sprintf('Results(%g).%s = replace',i,thisField);
                eval(commandLine);
            end
        end
    end
    Output = Results;
end            
back to top