class2str

Creates a Matlab-evaluable string which reconstructs a variable.
ダウンロード: 38
更新 2019/2/5

ライセンスの表示

This function creates a string containing Matlab code describing a variable.

class2str(this,data)
Create a string [ 'this = data;' ]
class2str(this, data, 'no comments')
same as above, but removes comments from the output file
class2str(this, data, 'eval')
creates a compact evaluable string of the initial data
class2str(this, data, 'flat')
creates a flat text with commented data blocks, which is not an m-file,
but rather a Linux-style config file.

input arguments:
this: string containing the name of the object to describe. Use '' to name the
root level from the input variable name, and ' ' to ignore root level
in structures.
data: any data set (struct, array, cell, char, objects)
options: optinal argument which may contain 'flat', 'no comments','eval'

output variables:
str: string which contains a function code to generate the data.

example:
data=struct('a',1,'b','a string comment','c',{'cell'});
str=class2str(data) % produces a string/script that regenerates data
str=class2str('this', data) % idem, but creates 'this' instead of 'data'.
str=class2str(data, 'flat') % a kind of config file
str=class2str(data, 'eval') % a compact evaluable string

See also: mat2str, num2str, eval, sprintf

Part of: Loaders utilities (ifit.mccode.org)
Author: E. Farhi <farhi@ill.fr>. Jan 2017
(c) E.Farhi, ILL. License: BSD.

引用

Emmanuel Farhi (2024). class2str (https://www.mathworks.com/matlabcentral/fileexchange/61093-class2str), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2010a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCharacters and Strings についてさらに検索
謝辞

ヒントを与えたファイル: structdlg: a dialogue to edit structures

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.1

fix for scalar which are also handles

1.0.0.0