App Designer: Slowdown when using antilog/exponential function

4 visualizaciones (últimos 30 días)
Akash G
Akash G el 24 de Oct. de 2016
Respondida: Steven Lord el 24 de Oct. de 2016
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
  2 comentarios
Sean de Wolski
Sean de Wolski el 24 de Oct. de 2016
How are you updating the plot?
Akash G
Akash G el 24 de Oct. de 2016
Using the standard plot function, is that what you're asking?

Iniciar sesión para comentar.

Respuestas (1)

Steven Lord
Steven Lord el 24 de Oct. de 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

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by