フィルターのクリア

Can matlab functions return a table?

18 ビュー (過去 30 日間)
Asghar
Asghar 2014 年 8 月 6 日
回答済み: Peter Perkins 2014 年 8 月 11 日
Hi, I am creating a matlab function and initializing a Table inside the function. I was wondering if I can return the (nxm)table with column headers as the return value of the Matlab function?
Thanks, Asghar

採用された回答

Iain
Iain 2014 年 8 月 6 日
You can return a cell array. This is an example of one.
cellarray = {'header 1', 'header 2'; 1 2; 45 76; 'Total' 78};
num2cell might be useful.

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2014 年 8 月 11 日
Asghar, in recent versions of MATLAB, there's a data type called "table". You may be asking about that. Here's a simple example of a function that returns such a table:
function t = createTable()
t = table(randn(3,1),randn(3,1),'VariableNames',{'X' 'Y'});
>> t = createTable
t =
X Y
________ _______
-0.43359 2.7694
0.34262 -1.3499
3.5784 3.0349

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by