matlab won't run any script or function

I couldn't run any function or script in matlab for 2 days now and it's killing me.
Lets say I have
disp('Hello world')
saved as hw.m in a path known to matlab. Sounds simple enough but I can't run this script. Hitting the run button in the gui yields
Undefined function or variable 'hw'
I tried to run hw.m from the command line...
run 'hw.m'
Undefined variable "hw" or class "hw.m".
Error in run (line 74)
evalin('caller',[script ';']);
Defining the script as a function didn't work either...

5 Kommentare

You've got something munged in path or aliased -- that whatever the function name is it's "ffs" that isn't being found is key.
Try
clear all
and
which ffs
BTW, you don't need run here, just
hw
from the command line suffices.
See what
matlabpath
returns; it's possible you've somehow munged it.
Pascal
Pascal am 6 Jul. 2014
Bearbeitet: Pascal am 6 Jul. 2014
Subsituted ffs with hw. Sorry this was a mistake in the question.
ahh, which hw gives me
[...]/hw.m % Has no license available
any idea why the license would be unavailable all of a sudden?
Taylor
Taylor am 10 Mär. 2017
Dear dpb,
Thank you for the clarification, I ran my script from another path and it worked.
Best regards, Taylor
Liana Mihaela
Liana Mihaela am 15 Mär. 2017
Hey, how can I run from another path ? Thank you!
Jorge Ramirez
Jorge Ramirez am 19 Aug. 2022
Yeap, I can confirm that the problem is the path your trying to run from, In my case I was trying to run from the bin folder inside the MATLAB installation folder in Linux, changed to my home directory and the problem was gone.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 6 Jul. 2014

1 Stimme

What toolbox was it in? What does "ver" show in the command window? Could it have been a temporary/trial license for that toolbox which expired?

7 Kommentare

Pascal
Pascal am 6 Jul. 2014
Bearbeitet: Pascal am 6 Jul. 2014
Don't quite get what you mean with "What toolbox was it in?". The problem occurs with each and every script or function I try to execute.
I use matlab on a university computer so I don't have much insights into licensing matters.
Output of ver:
ver
-------------------------------------------------------------------------------------------------------
MATLAB Version: 8.0.0.783 (R2012b)
MATLAB License Number: ••••••
Operating System: Linux 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64
Java Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------------------------
MATLAB Version 8.0 (R2012b)
It's not in base MATLAB so it must be in a toolbox or some custom written function that you think you have. You don't have any toolboxes at all installer. When you said which, why did it say
[...]/hw.m % Has no license available
Are you sure it didn't give a path rather than [...]? I've never seen it not give a full path if it found the file.
sure, it gave a path to my desktop where I saved hw.m. Sorry for the confusion. As stated in my question hw.m is only a test script I created that contains nothing but
disp('hello world')
(yes, my desktop folder has been added to path!)
Image Analyst
Image Analyst am 6 Jul. 2014
Weird. If it's your own function that you wrote, it should not be asking about a license. Does it still complain about the license if you put it in a different folder, like your "My documents" folder?
Pascal
Pascal am 6 Jul. 2014
Bearbeitet: Pascal am 6 Jul. 2014
Super weird indeed. Copying my files to a new folder doesn't fix it but everything works fine again after I generated a new file with identical code in another folder . Seems like some of the old files are corrupt if that makes any sense?
Image Analyst
Image Analyst am 6 Jul. 2014
Perhaps they have some invisible characters in there but it seems weird that that would cause it to say that some license is missing. I'd call the Mathworks and ask them. Is the hw file a standalone file that I can try to run, or does it need all kinds of other files? If you can post it, I could try it.
dpb
dpb am 10 Mär. 2017
Possible you inadvertently created (or broke) a path via a symbolic link so the path you think you're looking at isn't actually there at all? That kinda' thing sounds to me like what would bring in the licensing issues but I don't know diddley about Unix or the Matlab install on same; just a guess...

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Tags

Gefragt:

am 6 Jul. 2014

Kommentiert:

am 19 Aug. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by