Cannot display text from uitable1 to uitable 2 (column 1)
12 次查看(过去 30 天)
显示 更早的评论
function UpdateTrain_Callback(hObject, eventdata, handles)
%% Tombol Update Train
try
data = get(handles.uitable1,'data');
%jenis = char(data(:,1));
DataJ = string(data);
[Alternatif, Kriteria] = size(data);
dataN = zeros(1,6);
DataTraining = str2num(get(handles.tfDataTraining,'String'));
newAlternatif=1;
for x = 1:DataTraining
for y = 1:Kriteria
dataN(x,y) = DataJ(newAlternatif,y);
%fprintf('\nData Testing Bulan Ke - %d Tahun Ke - %d = %10.8f', y, th2, dataN(x,y));
end
newAlternatif=newAlternatif+1;
end
disp(dataN);
if all(cellfun(@isempty, data(:)))
msgbox('Data Is Still Empty','Warning','warn');
elseif isempty(DataTraining)
msgbox('Data Training Cannot Be Empty','Information','help');
elseif all(~cellfun(@isempty, data(:))) && ~isempty(DataTraining)
set(handles.uitable2, 'enable','on');
set(handles.uitable2,'data',dataN);
set(handles.UpdateTest, 'enable','on');
end
catch exception
msgbox(exception.identifier,'Error','error');
end
Someone please help me. I don't know how to fix this .... and I don't really know what matlab does.
this is the source code ....
I can't display text from uitable1 (column 1) to uitable 2 (column 1)
The explanation is in the picture!

1 个评论
Mario Malic
2020-10-3
This happens when you try to put a character/string array into a field that accepts a numeric value. Not sure if it's possible to change UITable field with set command, but if you access it this way, it should work.
table.data = values
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!