App Designer: Slowdown when using antilog/exponential function

2 次查看(过去 30 天)
Hello,
I have made an app that shows, among other things, an fft plot of some serial data that is received in real-time. It shows this fft as a logarithmic output so the noise floor is actually very high. To resolve this taken the antilog of the output with one line of code:
out = 2.^(out/512);
When I use this line the fft plot looks much better but after a minute the program gets VERY slow. Does anyone have any ideas why? Is there an alternative function to take the antilog of the output without using so much memory?
Cheers, Akash

回答(1 个)

Steven Lord
Steven Lord 2016-10-24
If you're calling plot in a loop, and the axes has been held using hold on, each iteration through the loop is adding one (or more) additional lines to the axes. As the number of lines grows, so does the time required to add new ones. Consider:
% Create data
x = 0:5:360;
% Initialize axes
ax = axes;
axis([0 360 -1 1]);
hold(ax, 'on')
% Plot in a loop and display how many lines are present
for k = 1:10
plot(x, sind(k*x));
c = findall(ax, 'Type', 'line');
fprintf('For k = %d, the axes has %d children.\n', k, length(c));
drawnow
end
Consider if you actually need all the lines at once. Compare the above with:
% Create data
x = 0:5:360;
% Initialize axes
ax = axes;
axis([0 360 -1 1]);
hold(ax, 'on')
% Plot one line at a time and display how many lines are present
h = plot(x, NaN(size(x)));
for k = 1:10
h.YData = sind(k*x);
c = findall(ax, 'Type', 'line');
fprintf('For k = %d, the axes has %d children.\n', k, length(c));
pause % so you can see each line
drawnow
end

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by