vars2cell

版本 1.3.0.0 (2.1 KB) 作者: Renwen Lin
% PURPOSE: Convert selected variables in matlab workspace to the cell's columns
180.0 次下载
更新时间 2012/9/12

查看许可证

% 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
%=============================================

引用格式

Renwen Lin (2024). vars2cell (https://www.mathworks.com/matlabcentral/fileexchange/38119-vars2cell), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2012a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.3.0.0

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

1.2.0.0

Modify the example. Thank you, Simon!

1.0.0.0