App Designer: The Value Assigned Might Not be Used
3 views (last 30 days)
Show older comments
William Pang
on 29 May 2020
Commented: William Pang
on 29 May 2020
Hello,
So I'm trying to read an image (2D matrix) on App Designer and run it through a function to do some filtering and analysis. I see the final value that I want (I just want to sum all the values in the image matrix after applying a filter) in the command window but when I try to make it display in a box I created with AppDesigner nothing shows up. On further inspection hoering on the "output" argument of the function, I see the message "The Value assigned to the variable 'Output' might be unused.
I'm also having trouble utilizing filter_size = app.FilterSizeEditField ... when I type in a value in the box and feed it through the function it pops back saying that "size inputs must be numeric"

filter_size = app.FilterSizeEditField;
%filter_size=3;
Output = trialfunction(app.I_M,filter_size)
Output = app.ValueEditField; %Display function output in the box
Here's the code for my trialfunction:
function[S]=trialfunction(I_M,filter_size);
I_bin_regions = rangefilt(I_M,ones(filter_size,filter_size));
S=sum(I_bin_regions,'all')
end
0 Comments
Accepted Answer
Geoff Hayes
on 29 May 2020
William - I think that you have your assignment reversed. Instead of
Output = trialfunction(app.I_M,filter_size)
Output = app.ValueEditField; %Display function output in the box
where, in the second line, you assign the edit field to the already assigned Output, you need to assign it to the field as
Output = trialfunction(app.I_M,filter_size)
app.ValueEditField = Output;
I'm assuming that Output is the correct data type for this field. Because you are now using this variable, the warning "The Value assigned to the variable 'Output' might be unused should be eliminated.
As for the message "size inputs must be numeric", this is probably due to your edit field being a text field rather than numeric (see uieditfield for details). So either you can change this field to be numeric, or you can convert your string input to a number. See convert text to numeric values for details.
3 Comments
Geoff Hayes
on 29 May 2020
Hi William - that was my mistake, you would need to do
app.ValueEditField.Value = 'some string';
app.ValueEditField.Value = num2str(Output);
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer 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!