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 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 ?
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 4 Sep. 2016
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!