필터 지우기
필터 지우기

Popup menu in uitable - There is no String property on the Table class.

조회 수: 2 (최근 30일)
I have this code and when I want to switch cases with the following code
listliterature={'Kim and Feng (2003) - Longitudinal', 'Kim and Feng (2003) - Transverse',...
'Sextos,Koilanitis and Moschonas (2011) - Bilinear' ,'Sextos,Koilanitis and Moschonas (2011)- Trilinear'...
'Guo A. et al.(2014)- After 100 years','Guo A. et al. (2014) - After 90 years','Guo A. et al. (2014) - After 80 years'...
'Guo A. et al. (2014) - After 70 years','Guo A. et al. (2014) - After 60 years','Guo A. et al. (2014) - After 30 years'...
'Guo A. et al. (2014) - Sound', 'Neilson G.(2015) - Rix - MSC Concrete'};
popup_column2 = 2;
col_fmt = get(handles.uitable1, 'ColumnFormat');
col_fmt{popup_column2} = listliterature
set(handles.uitable1, 'ColumnFormat', col_fmt);
str = get(hObject, 'String');
switch str
case 1... etc
I have this error:
Error using matlab.ui.control.Table/get
There is no String property on the Table class.
Error in main5>uitable1_CellEditCallback (line 206)
str = get(hObject, 'String')
How can I solve this problem? Thank you in advance

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 20일
You need to set the column to be editable.
To retrieve you need to get the Data property of the table, index that at the appropriate cell, and look at the value there.
  댓글 수: 3
Steven Lord
Steven Lord 2015년 9월 21일
I think you might have missed the most important part of Walter's suggestion. UITABLE objects do not have a String property; they have a Data property that contains the table data.
If your data is stored in the Data property as a numeric array, your cases should also be numeric. If your data is stored as a cell array containing strings, your cases should be strings. You can actually include both in the same case or include them in separate cases, as appropriate:
for k = {1, '1', 2, '2'}
x = k{1}; % First x will be the number 1, then the string '1', etc.
switch x
case {1, '1'}
disp('X is a 1');
case {2}
disp('X is the number 2');
otherwise
disp('X is the string ''2''');
end
end
Kelly Kyriakou
Kelly Kyriakou 2015년 9월 22일
Thank you both of you for your help! It was really precious!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by