Borrar filtros
Borrar filtros

Axes in App Designer hanging up when drawing on it

1 visualización (últimos 30 días)
Lewei He
Lewei He el 6 de Nov. de 2019
Comentada: Lewei He el 13 de En. de 2020
For some reason i need to re-implement a GUI that programmed directly with matlab into AppDesigner. There's a function in the old GUI that plot a Eletrodogram onto an axes object. I have tried to copy the function and directly use it in the AppDesigner, but everytime when i set the marker of Scatter, it takes very long to update and after the figure is showing on the App, matlab keeping busy with one core fully loaded (seems to be hanging up on some callbacks). Below are the function that i use in the AppDesigner and the Code for creating axes Object as well as the callback that calling the drawing function, attachment is the test file i used:
Creating the Axes and showing a logo, as well as loading the data:
kemarImg = imread(strcat(app.imgPath, 'kemar.jpg'));
app.axesPlot = axes(app.plotPanel, 'Position', [0.038 0.1 0.94 0.85]);
imshow(kemarImg, 'Parent', app.axesPlot)
app.testConfigData = load('PACEvmusic.mat');
A button that calls the Draw function:
function ButtonPushed(app, event)
app.drawElectrodogram(512, 24, app.testConfigData.loadedConfig.analysedSigPlot, 44100);
end
And finally the Draw Function:
methods (Access = private)
function drawElectrodogram(app, SamplePerFrame, electrodeCnt, analysedSigPlot, Fs)
app.axesPlot.Visible = false;
hSc = scatter(app.axesPlot, 0:22,0:22);
hSc.LineWidth = 15;
hSc.Marker = 'none';
app.axesPlot.YTick = 1:1:electrodeCnt;
app.axesPlot.Color = 'k';
teiler = 4;
temp = linspace(0,length(analysedSigPlot)*SamplePerFrame/Fs/teiler,length(analysedSigPlot));
x = repelem(temp,electrodeCnt);
temp = 1:electrodeCnt;
y = repmat(temp,1,length(analysedSigPlot));
colormap(app.axesPlot,'hot');
c = zeros(1,length(analysedSigPlot)*electrodeCnt);
hSc.XData = x;
hSc.YData = y;
hSc.LineWidth = 5;
% hSc.Marker = 'o';
% set(hSc,'XData',x,'YData',y,'CData',c,'LineWidth',5,'Marker','+');
app.axesPlot.Title.String = 'Electrodogram';
app.axesPlot.XLabel.String = 't / s';
app.axesPlot.YLabel.String = 'No. Electrode';
app.axesPlot.XAxis.Color = 'k';
app.axesPlot.YColor = 'k';
app.axesPlot.FontSize = 8;
% hold(app.axesPlot,"on");
for i = 0:2:length(analysedSigPlot)-1
c(electrodeCnt*i+1:electrodeCnt*(i+1)) = analysedSigPlot(:,i+1);
end
% set(hSc,'CData',c);
% drawnow;
% hold(app.axesPlot,"off");
hSc.CData = c;
disableDefaultInteractivity(app.axesPlot)
hSc.Marker = '.';
app.axesPlot.Visible = true;
end
end
Now, if i comment the line "hSc.Marker = '.' ", is takes a little while but shows an empty plot with black background (as it should be), if i let this line code there, the program just hanging up after clicking the button.

Respuestas (1)

Subhadeep Koley
Subhadeep Koley el 9 de En. de 2020
I have modified some portion of your code. Now, it is taking reasonable time to generate the output. See whether this is your expected output. electro.PNG
Refer the attached zip file for the modified .mlapp file.
Hope this helps!
  1 comentario
Lewei He
Lewei He el 13 de En. de 2020
i have tested your code, it works, when i replace my code in the mlapp, it takes much longer (well, it shows the picture in lesser than 1sec, but the GUI stays not respond after a few seconds), also the diagram is too small when i place it in my gui, even when i place the UIAxis in a Gridlayout. the attached zip file is the gui i made for testing, maybe you can help me to find out where is the trouble?
Btw. i have seen nothing changed between you modification and my code in the question (except that u used the mlapp component), is this the only position or i have overseen anything?

Iniciar sesión para comentar.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by