Code covered by the BSD License  

Highlights from
vars2cell

Be the first to rate this file! 6 Downloads (last 30 days) File Size: 2.11 KB File ID: #38119

vars2cell

by

 

11 Sep 2012 (Updated )

% PURPOSE: Convert selected variables in matlab workspace to the cell's columns

| Watch this File

File Information
Description

% PURPOSE: Convert selected variables in matlab workspace to the cell's columns
% -----------------------------------------------------------------------------
% SYNTAX:
% (1) vars2cell(var1, var2)
% (2) vars2cell(var1, var2, newvarnamelist)
% -----------------------------------------------------------------------------
% OUTPUT:
% (1) cellA: NxM --->a cell containing M columns. Each column include
% a head and its body.

% -----------------------------------------------------------------------
% INPUT:
% (1) var1, var2..., the variables (var1, var2, .., varM) in matlab workspace s been transform to columns of the cell
% (2) newvarname: 1xM ---> M string as new head for the column.

% -----------------------------------------------------------------------
% LIBRARY:
% -----------------------------------------------------------------------
% SEE ALSO: cell2vars,
% -----------------------------------------------------------------------
% REFERENCE: assigni, eval
% -----------------------------------------------------------------------
% written by:
% Lin Renwen
% <linrenwen@gmail.com>

% Version 1.0 [2012-9-8 13:47:28]
% Version 1.1 [2012-9-12 20:46:04] Modified the example. Thanks for Simon's suggestion!

%=============================================
% EXAMPLE:
% > name = {'Simon', 'Jimmy', 'Cooper'}';
% > grade = {99, 68, NaN}';
% > vars2cell(name, grade)
% ans =
% 'name' 'grade'
% 'Simon' [ 99]
% 'Jimmy' [ 68]
% 'Cooper' [ NaN]
%
% > vars2cell(name, grade,{'NAME','GRADE'})
% ans =
% 'NAME' 'GRADE'
% 'Simon' [ 99]
% 'Jimmy' [ 68]
% 'Cooper' [ NaN]

% END OF EXAMPLE
%=============================================

MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
12 Sep 2012 Renwen Lin

Thank you so much! I have modified the example! :) And the update the file.

12 Sep 2012 Jan Simon

I do not understand the posted example. Are "name" and "grade" strings, such that this is meant:
cellB = {'name', 'grade'; 1, 56; 2, 78; NaN, 90}
?

Updates
12 Sep 2012

Modify the example. Thank you, Simon!

12 Sep 2012

:)Thank you so much, Simon. I have modified the example and update the zip file.

Contact us