Creating a custom copy of a Matlab function (xlsread)

1 次查看(过去 30 天)
Hi,
I'm trying to create a copy of the xlsread function that will work slightly differently for my particular application.
What I tried is typing
edit xlsread
then going file/save as, and saving it in my working directory under a different name (and changing the function name to match its new file name).
When I try to use the new function, I get the following error:
??? XLSREAD unable to open test.xls. Undefined function or method 'validpath' for input arguments of type 'char'.
What is the problem?

采纳的回答

Andy
Andy 2011-5-11
If you type
which xlsread
you will see something like
C:\Program Files\MATLAB\R2009a\toolbox\matlab\iofun\xlsread.m
In the parent folder ...\iofun\, there is a subfolder ...\iofun\private, and this contains the function validpath. Mine is at:
C:\Program Files\MATLAB\R2009a\toolbox\matlab\iofun\private\validpath.m
If you also copy this file to the same location as your copy of xlsread, it should work. I highly recommend you change the name of the local copy of validpath (and change the call to it in your local copy of xlsread). It is clearly not a supported function, and may be used internally by other MATLAB functions. So if you altered your local file, you won't know what other consequences it might have.
Good luck.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by