Error in plot(app.UIAxes)
1 次查看(过去 30 天)
显示 更早的评论
f=app.SinefrequencySlider.Value;
a=app.SineAmplitudeSlider.Value;
w=2*pi*f;
na=app.NoiseAmplitudeSlider.Value;
t=0:0.01:100*pi;
x=a*sin(w*t);
n=numel(t);
y=na*rand(1,length(t));
sine=x+y;
for i=1:n
plot(app.UIAxes,t(1:i),sine(1:i)); %showing error in this line
drawnow;
end
10 个评论
Walter Roberson
2021-12-11
I predict that you need to turn the axes "hold" property on.
I also predict that you need to replace
for j=1:m
plot(app.UIAxes2,fs(1:j),mx(1:j));
drawnow;
end
with
if ~exist('hsin', 'var') || ~isvalid(hsin)
hsin = plot(app.UIAxes2, nan, nan);
end
for j=1:m
hsin.XData = fs(1:j);
hsin.YData = mx(1:j);
pause(t(2));
end
This will prevent you from continually generating new objects to draw into in your axes that has "hold" turned on.
The pause() is needed in order to get real-time. However, your data is sampled at 100 samples per second, and your graphics system might not be able to render at 100 frames per second, so it is not obvious what you want to do in this situation in order to maintain the real-time nature.
You would, generally speaking, want similar code structure in frequencydomainButton . However, you are plotting in the frequency domain, and it is not meaningful to talk about plotting in real-time in the frequency domain -- not unless you want to be doing spectrograms ??
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!