Is the brush tool available in compiled app via Matlab 2021b ?

Hello,
A section of the app that I created required the brush tool to be manually selected by the user on one of the figures displayed. I noticed that the brush tool is not visible once I compile the app. Am I correctly assuming that the tool is still not available in 2021b ? Or is there another way to call the tool ?
This is what I have on MatLab:
% Button pushed function: RemoveBrushedDataButton
function RemoveBrushedDataButtonPushed(app, event)
%remove brushed values from plot
app.BD = evalin('base','brushedData'); %get brushedData variable from base workspace
app.data1 = ismember(app.data,app.BD); %identify section of data that matches brushedData
app.data(app.data1) = NaN; %remove that section
% plot of data
app.figure1;
ax1 = app.figure1;
cla(ax1)
plot(ax1,app.data,'.b');
hold(ax1,'on');
end
So the code is using a variable named "brushedData" that is created by extracting highlighted data using the brush tool. Would there be another way to do this ?
Any help is appreciated, thank you!

4 Comments

Did you get any answer for this?, i'm havign the same problem
Hi, yes. I contacted the technical support team and they told me it was not available yet (2021b) unfortunately.
It seems that even for R2022a, it is not available to compile the brush option. I have the same problem @MathWorks Support Team

Sign in to comment.

Answers (3)

I have found a way to use the Brush tool on UIAxes in the appdesigner distribution app, including in the compilation, and have confirmed this with R2020b Update 8.
The point is to put a description in your mlapp that creates an instance of the Brush tool. This means the following:
function BrushButtonDown(app, event)
b = brush(app.UIAxes);
b.Enable = 'on';
% brush(app.UIAxes, 'on'); % this does not work on the distribution app.
end
On any distribution compiled app, the following icon settings seem to be ignored for UIAxes. So you need to prepare a callback to enable the functionality from the brush instance.
axtoolbar(app.UIAxes, {'zoomin', 'zoomout', 'rotate', 'restoreview', 'pan', 'datacursor', 'brush', 'export'});
I have created an instance in the form of a property variable in the startupFcn() like this:
function startupFcn(app)
app.Brush = brush(app.UIAxes);
end
...
function SelectToolButtonDown(app, event)
app.Brush.Enable = 'on';
end
If I just call brush() without creating an instance, the function may not be compiled, or the Brush icon is temporarily displayed but not in selection mode.

6 Comments

if its not too much trouble, could you create a basic mlapp that demonstrates what you describe above.
I am missing something when i try and implement what you have described and am frustruated beyond belief.
always gives me an unrecognized property error for brush, doesnt add the brush tool icon to the uiaxes. clearly i need some help. i am using 2022a.
I have created a simple demo. Please check if you can start brush with the button in the upper left corner.
Created with macOS 13.2.1 Matlab 2020b Update 8.
@Shinya Maruyama This was very helpful, immediatly saw what i was doing wrong.
Follow up question,
When you run this script does your brushed data highlight and persist after you are done brushing?
For me i get the red selection box, but nothing actually highlights.
app.UIAxes.Children.BrushData doesnt exist either.
If thats the case, I suppose this means brushed data within appdesigner is still very much broken in 2022a. sigh.
@John H. I compiled the above sample with Matlab R2022b Update5 and ran it on macOS. It worked no differently from R2020b in my environment.
If it does not work with my demo file, it is possible that brush does not compile on Windows or Linux environment, or it does not work with Matlab R2022a or its Update.
I will check again if it works on Windows.
man this is so annoying... i just want to be able to brush my data, lol
if you have a chance to verify on windows verses mac id appreciate it.
At least that would give me an inconsistent operation argument between OS's to submit to the the support team.
To be clear, i did not get the proper functionality in appdesigner, i didnt compile it yet. i figure if it doesnt work as an mlapp its not going to work as an exe .
@John H. Unfortunately, it worked on Windows in my environment. I wonder what is wrong with you? I hope it works.
My environment is Matlab R2020b Update8 Windows 10 Pro 21H2.

Sign in to comment.

i have the same issue, looking for an interactive cursor. The brush works while running inside matlab but after compiling, it doesn't show. I have tried Shinya's method and it doesn't work. I am using 2022a on windows 11. Can someone help?
I'm having the same issue and am not able to get Shinya's method to work either. I've built a number of data processing applications for my lab group that are now essentially non-functional in the compiled environment. Are there any plans to fix this issue in future releases? Does anyone else have a workaround?

Categories

Asked:

on 29 Nov 2021

Answered:

on 2 May 2024

Community Treasure Hunt

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

Start Hunting!