Plot function in app designer error "Not enough input arguments."
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
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 !
채택된 답변
Arthur Roué
2020년 7월 29일
x and y are structures, you need to select the correct field. For instance :
plot(app.UIAXes, x.freq_MHZ, i.iLdB)
댓글 수: 13
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"

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

Ok for UIAxes definition, can you add a breakpoint at your plot line and evaluate variable app.UIAxes, x and y ?
Yeah, i made a breakpoint on the plot and have this message :

I assume that app designer don't want to plot the x and y because it's an array.
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 ?
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.
And thank you for your time
Arthur Roué
2020년 7월 30일
편집: Arthur Roué
2020년 7월 30일
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);
Thank you very much ! I understand now ! Have a nice day !
Y a pas de quoi, tu peux maintenant fermer la question et/ou accepter la réponse !
Bonne journée ;)
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)
