function in app give "undefined function for input arguments"
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Sample of one of the functions in my code. I made functions for my 2 other apps and they worked fine once I included the correct inputs but I cannot get the correct inputs other than "app" for this code and it gives me a different error than I have seen. Code below:
function PostTestAONButton(app)
if app.MeasurementRangeAONButton.Value == 1
file = dir(fullfile(directory,'*POST-TEST*AON_.txt'));
for i = 1:numel(file)
filepath = fullfile(file(i).folder, file(i).name);
data_in = readmatrix(filepath);
% Grabbing only the frequency and SE values
x = data_in(:,1);
y = data_in(:,3);
% Plotting data based on various options selected
if app.IncludeonLegendCheckBoxAON.Value == 1
if app.MRMarkersButton.Value == 1
plot(x,y,"Color",app.MRColorDropDown.Value,'LineWidth',str2double(app.LineWidthDropDown.Value), ...
Marker=app.MRMarkerDropDown.Value,DisplayName='MR');
else
plot(x,y,"Color",app.MRColorDropDown.Value,'LineWidth',str2double(app.LineWidthDropDown.Value), ...
DisplayName='MR');
end
else
if app.MRMarkersButton.Value == 1
plot(x,y,'HandleVisibility','off',"Color",app.MRColorDropDown.Value,'LineWidth',str2double(app.LineWidthDropDown.Value), ...
Marker=app.MRMarkerDropDown.Value);
else
plot(x,y,'HandleVisibility','off',"Color",app.MRColorDropDown.Value,'LineWidth',str2double(app.LineWidthDropDown.Value));
end
end
end
else
end
end
7 Commenti
Voss
il 7 Feb 2023
@Walter Roberson: "before the definition of the nested function" I believe should be, "before the execution of the nested function"
outer % works
outer2 % fails
function outer
A = 5;
function C = inner % defining inner() here is ok, as long as B is defined before inner() is called
C = A + B;
end
B = 11; % B defined after the definition of inner() but before the execution of inner() works
inner()
end
function outer2
A = 5;
inner() % fails because B is not defined yet
function C = inner
C = A + B;
end
B = 11;
end
Walter Roberson
il 8 Feb 2023
Interesting, my memory had always been that the variable had to be defined before the nested function definition. Either that changed or my memory blipped again. Either of those are real possibilities ;-)
Risposte (0)
Vedere anche
Categorie
Scopri di più su Downloads in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!