Effacer les filtres
Effacer les filtres

Creating a custom copy of a Matlab function (xlsread)

1 vue (au cours des 30 derniers jours)
Denys
Denys le 11 Mai 2011
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?

Réponse acceptée

Andy
Andy le 11 Mai 2011
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.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by