Displaying the result of a pushbutton command in AppDesigner
Show older comments
Hello MATLAB Community,
I am trying to use the App Designer so that when I click the blue push button (this generates a random value), that randomly generated value will be displayed in the numeric edit field below.

Below I have what I tried: When the push button is clicked, a random value is generated.
The display(myfluor) displays the value in the command window but not the GUI. I attempted to assign the Value of the numeric edit field to the random variable but when the program is run, the field does not change. Any suggestions would be greatly appreciated, thank you!
% Button pushed function:
% RandomFluorescenceValueGeneratorButton
function RandomFluorescenceValueGeneratorButtonPushed(app, event)
a = 0; %min fluorescence
b = 1600; %max fluorescence
r = (b-a).*rand(1600,1) + a; %random vector of values generated from range a to b
myfluor = (randi(length(r))); %picking a random value in vector r to be the fluorescence value
display(myfluor)
end
% Value changed function: FluorescenceEditField
function FluorescenceEditFieldValueChanged(app, event)
app.FluorescenceEditField.Value = myfluor;
end
Accepted Answer
More Answers (0)
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!