Axes in App Designer hanging up when drawing on it
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (1)
Subhadeep Koley
am 9 Jan. 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.
Refer the attached zip file for the modified .mlapp file.
Hope this helps!
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!