Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

any2cell(input, dimensions)
function output = any2cell(input, dimensions)
% ANYCELL works similarly to num2cell, except uses size arguments instead of
% numel, which does not work for timer or serial objects.

% checks the number of arguments
error(nargchk(1, 2, nargin))

% if the input is empty
if isempty(input)
    % return an empty response (0x0 cell)
    output = {}; 

elseif nargin == 1
    % define the response the correct size
    output = cell(size(input));

    % for each item
    for m = 1:prod(size(input));
        % save it
        output{m} = input(m);

elseif nargin == 2;
    % call num2cell as normal, since it doesn't use numel if the dimensions
    % is supplied
    output = num2cell(input, dimensions);

Contact us