how to transmit the cell's value of 2 Columns to another 2 Columns in a uitable by clicking a Push Button (GUI && Matlab)

1 次查看(过去 30 天)
Hi everybody,
i want to transmit the Value off the ( Energie(t) && Predictive Energie(t) ) Columns to ( Energie(t-1) && Predictive Energie(t-1) ) after pushing a button (See atached Image)
by the first time clicking on my Button the Values off (Hauptantrieb, Klima,Heizung...) will be filled in the first two columns (( Energie(t) && Predictive Energie(t) )) but after hitting the Button again i want to transmit this Value to ( Energie(t-1) && Predictive Energie(t-1) ) Columns and at the same points i wanna get the current value of my Variables (Hauptantrieb, Klima,Heizung...) and put them in ( Energie(t) && Predictive Energie(t) ) Columns.
is like the result of my current Simulation, will be set by the next Simulation as past results.
does anybody how i can realise that ?

采纳的回答

Geoff Hayes
Geoff Hayes 2016-9-4
Alex - if you can assume that when you launch your GUI that all elements in the table are empty, then you can make the decision whether you need to move the first and second columns to the fourth and fifth respectively. Try
function pushbutton1_Callback(hObject, eventdata, handles)
% get the table data
tableData = get(handles.uitable1,'Data');
% if all elements in the first column are not empty then...
if all(~isempty(cell2mat(tableData(:,1))))
% move columns one and two to columns four and five
tableData(:,4) = tableData(:,1);
tableData(:,5) = tableData(:,2);
end
% update columns one and two with your data
tableData(:,1) = mat2cell(randi(255,6,1),ones(6,1));
tableData(:,2) = mat2cell(randi(255,6,1),ones(6,1));
set(handles.uitable1,'Data',tableData);
The use of randi is just an example. You would copy your data from elsewhere in order to populate these first two columns.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by