Update plot uitable problem

조회 수: 3 (최근 30일)
Hivanu Ince
Hivanu Ince 2019년 12월 9일
편집: Walter Roberson 2019년 12월 11일
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