Not enough input arguments error

4 visualizzazioni (ultimi 30 giorni)
Chris Gnam
Chris Gnam il 7 Apr 2016
Risposto: Walter Roberson il 7 Apr 2016
So I'm writing a code which accesses all of the .csv files in a specific folder, and then applies a specific type of curve fit to the data. I got all this to work perfectly fine, but now I want to make a GUI for the code. I'm running into an issue I don't really know how to solve. Here is the code I've reworked for the GUI so far:
%Generate the primary window
function main_window
main_window = figure('Position',[300 300 1000 500], 'MenuBar', 'none', 'ToolBar', 'none',...
'NumberTitle','off','Name','Curve Fitting for SORA Science Team')
clearvars -except main_window
t = uicontrol(main_window,'Style','text',...
'String','To use this curve fitting application, simply select a folder containing your desired .csv files. This program will automatically apply an 8-term Fourier Series as the fitted curve, though if this is not sufficient you can launch the curve fitting toolbox and manually fit the curve. Once all of your data sets have been curve fitted, click the integrate button to produce compare data sets.',...
'Position',[10 20 200 200]);
file_panel = uipanel('Title','Files in Session','FontSize',8,...
'Position',[.01 .507 .2 .46]);
file_list = uicontrol(file_panel,'Style','listbox',...
'Position',[10 60 176 150],'Value',1);
load_file_btn = uicontrol(file_panel,'Style','pushbutton','String','Load New Files',...
'Position',[10 10 100 40],'Callback', @load_files);
plot_panel = uipanel('Title','Curve Fitted Plots','FontSize',8,...
'Position',[.22 .07 .77 .9]);
tgroup = uitabgroup('Parent', plot_panel);
end
function load_files(hObject, eventdata, handles)
Folder_Location = uigetdir;
d = dir([Folder_Location, '\*.csv']);
n = length(d);
All_Files = dir( fullfile(Folder_Location,'*.csv') );
All_Files = {All_Files.name}';
set(handles.file_list, 'String', char(All_Files));
end
When run the following error is given:
Not enough input arguments.
Error in plot_test>load_files (line 25)
set(handles.file_list, 'String', char(All_Files));
Error while evaluating UIControl Callback
Any idea what the problem might be? It does everything properly but then gets hung up on the last line where I try to print out all of the file names into a list box.

Risposte (1)

Walter Roberson
Walter Roberson il 7 Apr 2016
You have
load_file_btn = uicontrol(file_panel,'Style','pushbutton','String','Load New Files',...
'Position',[10 10 100 40],'Callback', @load_files);
By default, MATLAB passes only two parameters to the callback. Your routine
function load_files(hObject, eventdata, handles)
expects 3 parameters.
If you did manage to pass in handles then you would just have postponed the problem, as there is no files_list field in handles

Categorie

Scopri di più su Environment and Settings 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!

Translated by