matlab的drawmode,matlab – 提升App Designer UI元素的刷新率

我目前正在尝试显示我在Matlab应用程序设计器应用程序中通过串口接收的数据.我正在遭受线性仪表的极差刷新率(~1 Hz).

仪表的值由固定速率定时器更新,定时器设置为30Hz.

计时器回调中的时间戳打印显示我以正确的频率调用它.我的计算机非常强大,任务管理器没有显示任何高负载的迹象 – 实际上,MATLAB应用程序几乎不消耗任何CPU时间.它实际上不仅仅是仪表而是所有UI元素.

所以我的猜测 – 或更好:我的希望 – 是刷新率必须有一些硬性上限.但是,官方文档没有提供有关如何更改此内容的任何提示.

我的MATLAB版本是R2016b.

所以我的问题:

>这是用R2017a修复的吗?

>如果没有:我可以做些什么,即摆弄MATLAB内置文件吗?

这是一个MCV示例,演示了这个问题:

classdef testapp < matlab.apps.AppBase

% Properties that correspond to app components

properties (Access = public)

UIFigure matlab.ui.Figure

andwatchhowthisstartstospinsmoothlyGaugeLabel matlab.ui.control.Label

andwatchhowthisstartstospinsmoothlyGauge matlab.ui.control.SemicircularGauge

KeepturninghereKnobLabel matlab.ui.control.Label

KeepturninghereKnob matlab.ui.control.Knob

end

properties (Access = private)

tim_the_timer

i = 0;

end

methods (Access = private)

function app = refreshMeter(app, ~,~)

% display timestamp

datestr(now,'HH:MM:SS.FFF')

% update the gauge

app.andwatchhowthisstartstospinsmoothlyGauge.Value = app.i;

app.i = app.i + 1;

if app.i > 100

app.i = 0;

end

end

end

methods (Access = private)

% Code that executes after component creation

function startupFcn(app)

t = timer;

t.TimerFcn = @app.refreshMeter;

t.Period = 0.02;

t.BusyMode = 'drop';

t.ExecutionMode = 'fixedRate';

start(t);

app.tim_the_timer = t;

end

% Close request function: UIFigure

function UIFigureCloseRequest(app, event)

stop(app.tim_the_timer);

delete(app.tim_the_timer);

delete(app);

end

end

% App initialization and construction

methods (Access = private)

% Create UIFigure and components

function createComponents(app)

% Create UIFigure

app.UIFigure = uifigure;

app.UIFigure.Position = [100 100 640 480];

app.UIFigure.Name = 'UI Figure';

app.UIFigure.CloseRequestFcn = createCallbackFcn(app, @UIFigureCloseRequest, true);

setAutoResize(app, app.UIFigure, true)

% Create andwatchhowthisstartstospinsmoothlyGaugeLabel

app.andwatchhowthisstartstospinsmoothlyGaugeLabel = uilabel(app.UIFigure);

app.andwatchhowthisstartstospinsmoothlyGaugeLabel.HorizontalAlignment = 'center';

app.andwatchhowthisstartstospinsmoothlyGaugeLabel.Position = [275 138 246 15];

app.andwatchhowthisstartstospinsmoothlyGaugeLabel.Text = '... and watch how this starts to spin smoothly';

% Create andwatchhowthisstartstospinsmoothlyGauge

app.andwatchhowthisstartstospinsmoothlyGauge = uigauge(app.UIFigure, 'semicircular');

app.andwatchhowthisstartstospinsmoothlyGauge.Position = [338 168 120 65];

% Create KeepturninghereKnobLabel

app.KeepturninghereKnobLabel = uilabel(app.UIFigure);

app.KeepturninghereKnobLabel.HorizontalAlignment = 'center';

app.KeepturninghereKnobLabel.Position = [119 265 112 15];

app.KeepturninghereKnobLabel.Text = 'Keep turning here...';

% Create KeepturninghereKnob

app.KeepturninghereKnob = uiknob(app.UIFigure, 'continuous');

app.KeepturninghereKnob.Position = [145 314 60 60];

end

end

methods (Access = public)

% Construct app

function app = testapp()

% Create and configure components

createComponents(app)

% Register the app with App Designer

registerApp(app, app.UIFigure)

% Execute the startup function

runStartupFcn(app, @startupFcn)

if nargout == 0

clear app

end

end

% Code that executes before app deletion

function delete(app)

% Delete UIFigure when app is deleted

delete(app.UIFigure)

end

end

end

编辑:当我转动旋钮,滑块等时,我注意到仪表会立即更新.所以不知何故,更高的刷新率的能力肯定存在……但如何启用它而不必触摸控件?相应更新了MCV.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值