Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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 ?

Réponse acceptée

Geoff Hayes
Geoff Hayes le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by