美文网首页MATLAB学习
2020-03-02 MATLAB App Designer——

2020-03-02 MATLAB App Designer——

作者: _何_其_ | 来源:发表于2020-03-02 09:26 被阅读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

相关文章

网友评论

    本文标题:2020-03-02 MATLAB App Designer——

    本文链接:https://www.haomeiwen.com/subject/blnukhtx.html