Update plot uitable problem

3 vues (au cours des 30 derniers jours)
Hivanu Ince
Hivanu Ince le 9 Déc 2019
hey, I'm a Matlab beginner and I need help...
I've got a 2x2 table to define an area. I've created a ui within my function just to show the table and plot the area. this is how far I am right now. what's left is that I'd like the plot to update when the values in the table change. the values are editable but the plot remains the same.
any help is appreciated!!
t = table(Drehzahl, Drehmoment, 'RowNames',{'Startpunkt' 'P1' 'P2' 'P3' 'Endpunkt'});
fig = uifigure;
fig.Position(3:4) = [822 360];
uit = uitable(fig,'ColumnEditable',true);
uit.Data = t;
uit.FontSize = 10;
uit.FontWeight = 'bold';
uit.ColumnEditable = true;
uit.Position(3) = 375;
ax = uiaxes(fig);
ax.Position(1) = 415;
ax.YLabel.String = 'Drehmoment [Nm]';
ax.XLabel.String = 'Drehzahl [rpm]';
x = t{:,1};
y = t{:,2};
area(ax,x,y);
ax.XLim = [0 45];
ax.YLim = [0 2000];
ax.Title.String = 'Feld der gefahrenen Punkte';
  1 commentaire
Ankit
Ankit le 10 Déc 2019
You can use DisplayDataChangedFcn callback but it is available in r2019. I have not seen it in 2018b or previous release.

Connectez-vous pour commenter.

Réponse acceptée

Ankit
Ankit le 10 Déc 2019
After a while, I found a solution to this problem:
t = table(Drehzahl, Drehmoment, 'RowNames',{'Startpunkt' 'P1' 'P2' 'P3' 'Endpunkt'});
fig = uifigure;
fig.Position(3:4) = [822 360];
uit = uitable(fig,'ColumnEditable',true);
uit.Data = t;
uit.FontSize = 10;
uit.FontWeight = 'bold';
uit.ColumnEditable = true;
uit.Position(3) = 375;
uit.CellEditCallback = @updateFigure;
ax = uiaxes(fig);
ax.Position(1) = 415;
ax.YLabel.String = 'Drehmoment [Nm]';
ax.XLabel.String = 'Drehzahl [rpm]';
x = t{:,1};
y = t{:,2};
area(ax,x,y);
ax.XLim = [0 45];
ax.YLim = [0 2000];
ax.Title.String = 'Feld der gefahrenen Punkte';
function updateFigure(src,event)
x = uit.Data(:,1);
y = uit.Data(:,2);
area(ax,x,y)
end
  1 commentaire
Hivanu Ince
Hivanu Ince le 11 Déc 2019
that worked perfectly, thank you so much!
do you know, how the new edited values can be stored in a vector??

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by