Update plot uitable problem

3 次查看(过去 30 天)
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 个评论
Ankit
Ankit 2019-12-10
You can use DisplayDataChangedFcn callback but it is available in r2019. I have not seen it in 2018b or previous release.

请先登录,再进行评论。

采纳的回答

Ankit
Ankit 2019-12-10
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 个评论
Hivanu Ince
Hivanu Ince 2019-12-11
that worked perfectly, thank you so much!
do you know, how the new edited values can be stored in a vector??

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by