having trouble to insert text in GUI table
Ältere Kommentare anzeigen
I want to make a table, 'uitable', with 4 collumns and a variable number of rows. The number of rows is determined by an edit text box, 'edit1'. The problem is that I want to insert text in the first collumn, but as soon as i insert any caracter that is not a number, the cell automatically goes to NaN. Can you help me?
edit1 = str2num(char(get(hObject,'String')));
if ~isempty(edit1) && edit1>0
edit1 = ceil(edit1);
data = cell(edit1,4);
% convert the values matrix to a cell array
valuesAsCell = mat2cell(data);
% update the table
set(handles.uitable,'Data',valuesAsCell{:});
end
Akzeptierte Antwort
Weitere Antworten (1)
Zoltán Csáti
am 23 Jan. 2015
It is because you supplied a string. Convert it to number.
edit1 = str2num(edit1);
edit1 = ceil(edit1);
...
3 Kommentare
Diogo Queirós
am 23 Jan. 2015
Zoltán Csáti
am 23 Jan. 2015
Could you send me your program. I would look at it.
Diogo Queirós
am 24 Jan. 2015
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!