replace number with string in uitable

I have a very simple code in my gui where I want X and Y values to appear in a uitable. I want the last column to be editable so I can replace some of the numbers with characters (or string). But when I try with my code below the characters I set in are automatically replaced with NaN. How do I keep the character/string in the uitable cell?
My code:
Y=[0.5360; 0.3490; 0.1990; 0.1190; 0.0780; 0.0560];
X=[12; 10; 8; 6; 4; 2];
T1=[X Y X Y];
T1=num2cell(T1);
set( handles.uitable1, 'Data', T1);

 採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 17 日

1 投票

After your

 T1=num2cell(T1);

do

T1(:,end) = cellfun(@num2str, T1(:,end), 'uniform', 0);

Then

set( handles.uitable1, 'Data', T1, 'ColumnFormat', {'numeric', 'numeric', 'numeric', 'char'})

1 件のコメント

JB
JB 2018 年 4 月 18 日
PERFECT, thanks a lot Walter Roberson

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

タグ

質問済み:

JB
2018 年 4 月 17 日

コメント済み:

JB
2018 年 4 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by