MATLAB Answers

replace number with string in uitable

조회 수: 24(최근 30일)
JB 17 Apr 2018
Commented: JB 18 Apr 2018
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];
set( handles.uitable1, 'Data', T1);

  댓글 수: 0

로그인 to comment.

채택된 답변

Walter Roberson
Walter Roberson 17 Apr 2018

After your



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


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

  댓글 수: 1

JB 18 Apr 2018
PERFECT, thanks a lot Walter Roberson

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.



Translated by