Hello,
I am having issues programmatically adding componenets to my app designer code and then writing a callback function for the changing of those values (while outside of the creation function, read below).
I have 2 instances of this issue. I will try to make it clear how I receive ther error.
CASE 1:
I programmatically generate NumericEditField components and have a function that is outside of the generation function. e.i.
function createCH_Freq_Edit_Fields(app,app.numelements)
for CH = 1:numelements
app.CH_Freq_Edit_Fields(CH) = uieditfield(app.CHPanel, 'numeric');
set(app.CH_Freq_Edit_Fields(CH),'ValueChangedFcn',@CH_FreqsChanged);
end
end
function CH_FreqsChanged(app,event)
for CH = 1:app.numelements
app.Freq_values = get(app.CH_Freq_Edit_Fields(CH),'Value');
end
end
I get an error however. The error is: "Undefined function 'CH_FreqsChanged' for input arguments of type 'matlab.ui.control.NumericEditField'."
CASE 2:
I programmatically generate StateButton components and have a function that is outside of the generation function. e.i.
function createCH_Select_Plot(app,app.numelements)
for CH = 1:app.numelements
CHSelectW(CH) = uibutton(bgWave,'state');
CHSelectW(CH).ValueChangedFcn = @CHButtonValueChanged;
end
end
function CHButtonValueChanged(app,event)
for i = 1:numelements
CHSelection(1,i) = CHSelectW(i).Value;
CHSelectionSUM(i) = sum(CHSelection(:,i));
if CHSelectionSUM(i) == 1 || CHSelectionSUM(i) == 3
elseif CHSelectionSUM(i) == 2 || CHSelectionSUM(i) == 0
end
end
end
Here, I return an error "Undefined function 'CHButtonValueChanged' for input arguments of type 'matlab.ui.control.StateButton'."
Question:
Question is, how do I fix this? I have seen my callbacks work if I place the ValueChangeFcn inside of the creation function, but then these functions are not referencable in other functions later on. I would like to have other functions change the values and execute the callbacks programmatically.
How can I rewrite these functions to receive these ui components as inputs?
P.S. I am using Matlab 2019b Update 4 and working exclusively in App Designer. NOT GUIDE. I have a long list of functions in conjunction with app designer made functions in my app. It would be best if we can make it work on this platform, not GUIDE.
Thanks in advanced!