필터 지우기
필터 지우기

Fileparts error

조회 수: 9 (최근 30일)
Jaejin Hwang
Jaejin Hwang 2012년 1월 3일
If I run on Matlab 2011b, there is an error like that Error using fileparts Too many output arguments.
Is there alternative way to solve the problem?
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 1월 3일
Could you post an example?
Could you post the traceback? I'm thinking there is a chance that one of your own functions might be overriding something that fileparts uses.
Jaejin Hwang
Jaejin Hwang 2012년 1월 4일
This is the error. When I use it on 2009a, it is working well.
Error using fileparts
Too many output arguments.
Error in mri_summary (line 21)
[pathstr, name, ext, versn] = fileparts(mess.Name);
Error in mri_gui>SelectInputFile_Callback (line 89)
subject = mri_summary(fullfile(PathName, FileName));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in mri_gui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)mri_gui('SelectInputFile_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2012년 1월 3일
Are you using some code from a prior version where it could take 4 output arguments? Take note of this note:
Note The fourth output argument of fileparts (file version) is no longer supported and has been removed. Calling the function with more than three output arguments generates a warning and will error in a future version.
  댓글 수: 1
Friedrich
Friedrich 2012년 1월 4일
Yepp. This is a typo in 11b. In 11b the warning was removed and became an error. So remove the 4th output of fileparts to get it working.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Iain Robinson
Iain Robinson 2012년 7월 18일
Jaejin, the error is caused because the syntax for the fileparts function has changed between versions of MATLAB.
In MATLAB 2009b (and earlier versions?), the old syntax was:
[pathstr, name, ext, versn] = fileparts(filename)
From MATLAB 2011a onwards the new syntax is:
[pathstr, name, ext] = fileparts(filename)
Using the old syntax in MATLAB 2011a or MATLAB 2011b will generate a warning.
Using the old syntax in MATLAB 2012a will generate an error.
I haven't tested this, but I think if you use the new syntax in any version from MATLAB 2009b onwards it will still work. This is because MATLAB will ignore function outputs that aren't assigned to a variable. By the way, be careful if you are using ~ notation (the tilde) to ignore output arguments. This feature was introduced in MATLAB 2009b, so will break compatibility with earlier versions.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by