Matlab cannot run a *.m file
Show older comments
I have an script named Cast_Analysis.m. I have already run it and it was working, but according to memory constraints the simulation was aborted. I had to restart Matlab but when tried to run it again Matlab keeps returning the following message:
Undefined function or variable 'Cast_Analysis'
I have tried to run it from the command window, from the run button in the editor tab and F5 button
The file, is stored under: C:\Users\emcirugedaroldan\Desktop\MatlabCoding\scripts\
i have checked that Matlab is able to find the file:
>> exist('Cast_Analysis')
ans =
2
I have checked Matlab has rights to execute it
>> fileattrib('Cast_Analysis.m')
Name: 'C:\Users\emcirugedaroldan\Desktop\MatlabCoding\scripts\Cast_Analysis.m'
archive: 1
system: 0
hidden: 0
directory: 0
UserRead: 1
UserWrite: 1
UserExecute: 1
GroupRead: NaN
GroupWrite: NaN
GroupExecute: NaN
OtherRead: NaN
OtherWrite: NaN
OtherExecute: NaN
I have checked Matlab finds the file in the specified directory
>> what(pwd)
MATLAB Code files in folder C:\Users\emcirugedaroldan\Desktop\MatlabCoding\scripts
Arrythmia_testing EstHRV PhysioNet_DB_Download_qrs mti
CAST_DB EstRR fn2fm spbrk
Cast_Analysis PhysioNet_DB_Download fnbrk spval
ComputeTime PhysioNet_DB_Download_noAnnot fnval
Can someone help me with it?
5 Comments
It is possible that there are multiple Mfiles with the same name on your MATLAB path? Try:
which Cast_Analysis -all
John D'Errico
on 27 Jul 2016
Edited: John D'Errico
on 27 Jul 2016
That would not cause the indicated error message though.
I'm wondering if the file was not closed properly when MATLAB crashed, thus somehow corrupted.
Image Analyst
on 27 Jul 2016
So you ran it, your program crashed, and when you started MATLAB and changed the current folder to the folder of Cast_Analysis.m, it says it's undefined? Does it still not run after a full reboot of the computer? Or no - it just ran one single time and after that it won't run at all, ever?
How are you trying to run it? The F5 key, the green triangle button on the tool ribbon, or typing the name onto the command line? Have you tried all 3 ways of running it?
Does the m-file require any input arguments?
Eva Maria Cirugeda Roldan
on 28 Jul 2016
John D'Errico
on 28 Jul 2016
You need to have that folder on your search path though. If you created a new folder, that new folder needs to be on the search path.
You can do that by using CD inside MATLAB to move to the new folder. Or you can use addpath or pathtool to add the folder to the path.
Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!