function acts differently in command window to when its run in a .m file.
Mostra commenti meno recenti
Hello, so I'm having this problem with the exist command.
I have a program PlotDep.m which uses a function getFileName.m to get a file name, next I check to see if the filename exists which works and that works fine. I want to run PlotDep.m several times over so I turned it into a function and created a new program to run and get a batch of plots, this file is called covarianceBatch.m.
When I run the covarianceBatch.m it is supposed to run the
PlotDep(mode(a), sampleTime(b), model(c), height(d))
function over and over again but I get the error
Undefined function or method 'exist' for input arguments of type 'cell'
end
which corresponds to the lines of code in PlotDep.m
filename = getFileName(radar, sYear, sMonth, sDay, model);
if exist(filename, 'file');
if i run
PlotDep(mode(a), sampleTime(b), model(c), height(d))
in the command window it works fine? Any idea why this could be?
1 Commento
Star Strider
il 28 Lug 2012
Modificato: Star Strider
il 28 Lug 2012
I suggest you explore the documentation for the ‘which’ function: http://www.mathworks.com/help/techdoc/ref/which.html. It may provide you with the information you want.
If your ‘PlotDep.m’ file isn't too long, please post all of it.
I can't find any information on the ‘getFileName’ function. If you wrote it, you need to post the code for it as well.
Risposte (3)
Wayne King
il 28 Lug 2012
Modificato: Wayne King
il 28 Lug 2012
What is getFileName returning? We need to know what that looks like
For example, if you run it from the command line
>>filename = getFileName(radar, sYear, sMonth, sDay, model);
>> whos filename
returns what?
Depending on what that returns, you may be able to fix your code with
if exist(char(filename), 'file')
Oleg Komarov
il 28 Lug 2012
Modificato: Oleg Komarov
il 28 Lug 2012
0 voti
As the error message suggests, one of the inputs to the exist function is probably a cell type.
In the cmd window type
dbstop if error
then run the covarianceBatch and check the inputs once it errors.
Finally,
dbclear if error
to reset.
Star Strider
il 28 Lug 2012
0 voti
I suggest you explore the documentation for the ‘which’ function: http://www.mathworks.com/help/techdoc/ref/which.html. It may provide you with the information you want.
If your ‘PlotDep.m’ file isn't too long, please post all of it.
I can't find any information on the ‘getFileName’ function. If you wrote it, you need to post the code for it as well.
Categorie
Scopri di più su Debugging and Analysis in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!