function result = operation(oper,data1,data2) result = []; if length(data1) ~= length(data2) return end l = length(data1; result = ones(l,1) * NaN; switch (oper) case '+' for n = 1 : l if ~isnan(data1(n)) && ~isnan(data2(n)) result(n) = data1(n) + data2(n); elseif ~isnan(data1(n)) && isnan(data2(n)) elseif ~isnan(data1(n)) && isnan(data2(n)) end end case '-' end end