https://github.com/simkind/Patch-clamp-analysis
Raw File
Tip revision: bde5c7399d9f7c789feec0ee26ab5dad4a661d90 authored by simkind on 13 January 2021, 04:40:28 UTC
Create How to use.md
Tip revision: bde5c73
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