2020-03-02 MATLAB App Designer——
2020-03-02 本文已影响0人
_何_其_
1. matlab自定义回调函数语法法则
2. 在Callback函数中插入
function tsunamisData % 回调函数
t = readtable('tsunamis.xlsx');
vars = {'Year','MaxHeight','Latitude','Longitude'};
t = t(1:20,vars);
fig = uifigure;
fig.Position(3:4) = [822 360];
uit = uitable(fig);
uit.Data = t;
uit.ColumnSortable = [false true true true];
uit.ColumnEditable = true;
uit.Position(3) = 375;
uit.DisplayDataChangedFcn = @updatePlot; % 配置回调函数的方法是在该函数体内增加一个function
ax = uiaxes(fig);
ax.Position(1) = 415;
ax.YLabel.String = 'Max Height';
x = t.Year;
y = t.MaxHeight;
area(ax,x,y)
function updatePlot(src,event) % 回调函数
t = uit.DisplayData;
x = t.Year;
y = t.MaxHeight;
area(ax,x,y)
end
end