Plot function in app designer error "Not enough input arguments."
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Hello every one,
I'm working on a little project where the main goal is to read a big excel file (xlsx) and extract information which interest me.
I need to make table and plot some value from this excel.
I import the excel file with the function readtable. However, when i want to plot with the data in the table, i have the following error :
Error using plot
Not enough input arguments.
Error in app2/ButtonPushed (line 53)
plot(app.UIAxes,x,y);
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.

Thank you and i hope someone will help me !
Accepted Answer
Arthur Roué
on 29 Jul 2020
x and y are structures, you need to select the correct field. For instance :
plot(app.UIAXes, x.freq_MHZ, i.iLdB)
13 Comments
Karol Szczech
on 29 Jul 2020
Well actually, i made a mistake, th real code is the following one :
i use the function "table2array" and not "table2struct".
If i let the same code, i still have the error "Error using plot Not enough input arguments"

Karol Szczech
on 29 Jul 2020
Which is weird, because i put the good amount of input arguments.
Arthur Roué
on 29 Jul 2020
Indeed it's kinda weird.
Can you share the content of app.UIAxes, x and y ?
Karol Szczech
on 30 Jul 2020
Hey,
here's the code
Maybe i can change the XTick for an {} and not a [] ?

Arthur Roué
on 30 Jul 2020
Ok for UIAxes definition, can you add a breakpoint at your plot line and evaluate variable app.UIAxes, x and y ?
Karol Szczech
on 30 Jul 2020
Yeah, i made a breakpoint on the plot and have this message :

Karol Szczech
on 30 Jul 2020
I assume that app designer don't want to plot the x and y because it's an array.
Arthur Roué
on 30 Jul 2020
Can you set the breakpoint before throwing the error ? I wanted to know the content of app.UIAxes, x and y before evaluation. Or better, can you share your app with the xlsxa data file ?
Karol Szczech
on 30 Jul 2020
Yeah, i think it's better if i share the project. It's the first time i have this error and i'm a little lost.
Karol Szczech
on 30 Jul 2020
And thank you for your time
Arthur Roué
on 30 Jul 2020
Edited: Arthur Roué
on 30 Jul 2020
Your problem is that x and y are cell-str because you use a table, plot function only take numerical arrays as input. If you load your data with readmatrix instead of readtable, it would be ok.
Now, if you want to keep a table object, you need to process a bit your x and y data before plotting
t = readtable('graphTest2_clean2.xlsx', 'Sheet', 1);
%ab = table2array(t);
app.UITable .Data = t; % associe le tableau excel à la var t
t.Properties.VariableNames{1} = 'freq_MHz';
t.Properties.VariableNames{2} = 'iLdB';
t.Properties.VariableNames{3} = 'pair12';
t.Properties.VariableNames{4} = 'pair34';
t.Properties.VariableNames{5} = 'NextdB';
t.Properties.VariableNames{6} = 'NextPair1236';
t.Properties.VariableNames{7} = 'RLdBLimit';
t.Properties.VariableNames{8} = 'RLpair12';
t.Properties.VariableNames{9} = 'RLPair36';
app.UITable.ColumnName = t.Properties.VariableNames ;
%x = ab(5:45,1);
% Get columns of table t
x = t.freq_MHz;
y = t.iLdB;
% There are empty values at the end of y. They are replaced by
% 'NaN' beforr numerical conversion
y(cellfun(@isempty, y)) = {'NaN'};
% Convert x and from cell-str to numerical array
x = cellfun(@str2num, x);
y = cellfun(@str2num, y);
% Plot
plot(app.UIAxes, x, y);
Karol Szczech
on 30 Jul 2020
Thank you very much ! I understand now ! Have a nice day !
Arthur Roué
on 30 Jul 2020
Y a pas de quoi, tu peux maintenant fermer la question et/ou accepter la réponse !
Bonne journée ;)
More Answers (0)
Categories
Find more on Tables in Help Center and File Exchange
Products
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)