Clear Filters
Clear Filters

App Designer: Slowdown when using antilog/exponential function

2 views (last 30 days)
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

Answers (1)

Steven Lord
Steven Lord on 24 Oct 2016
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

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!