/
MATLAB

MATLAB

fileparts version obsolete (error in 2015 versions of MATLAB)

If you have a matlab command line like

[p,f,e,v] = fileparts( filename );

MATLAB will give an error like this:

Error using fileparts
Too many output arguments.

The 4th output argument ("v" in our example) needs to be deleted, along with the preceding comma:

[p,f,e] = fileparts( filename );

FYI: fileparts separates a filename into path (folder), filename, and extension. 

Fixing an error

Follow these steps to fix a fileparts error.

1) Identify the m-file and line number where the problem is. For example, for the following error message

Error using fileparts
Too many output arguments.
                   
Error in ==> wfu_spm at 168           

the file "wfu_spm.m" has the error at line 168.

2) Open this file in the MATLAB editor:

>>edit wfm_spm

3) Go to the line with the problem (168 in our example)

4) Delete the 4th output variable (and the comma before it), as in the example above where ",v" was removed.

5) Save the file; you can close the editor.

Note that oftentimes there are more than one usage of fileparts in a file or set of programs, so you may need to repeat this correction several times.

GUI/GUIDE slowdown

Use this command to clear memory: java.lang.System.gc()

mex-files

Notes on setting up matlab R2007a/b at mathworks. Note that 32 and 64 bit mex-files are different.

Listbox: coloring individual lines

Here's an example for both background and font:

% list contains entires;
for i = 1:length(list)
    list_colored{i} = sprintf( '<html><DIV bgcolor="yellow"><font color="red">%s</font></DIV></html>', list{i} );
end
set(handles.group,'String',list_colored)

See further info.

Related content

MATLAB Startup
MATLAB Startup
More like this
MATLAB installation notes
MATLAB installation notes
More like this
CONN Programming Notes
CONN Programming Notes
More like this
Installing MATLAB for CSPM
Installing MATLAB for CSPM
More like this
Updates 2022
Updates 2022
More like this
Format of MATLAB files exported from AcqKnowledge
Format of MATLAB files exported from AcqKnowledge
More like this