Function run(scriptname) doesn't work.
이전 댓글 표시
when i try to execute my script from command:
run('C:\Users\hello.m')
==> nothing happens (no error).
my script 'hello.m' is not executed. however, if i use matlab editor to run this script. It works.
Somebody can tell me why and help me figure out the solution, please!
when i use the commande "echo on all" to check.
normally it displays:
% Finally, evaluate the script if it exists and isn't a shadowed script.
evalin('caller', [script ';']);
***************************** hello ***********************
**************************** i am son*******
*********************************************************
*********************************************************
*****************************---------------*******************************
*********************************
*********************************
*********************************
delete(cleaner);
however, on my PC it displays:
% Finally, evaluate the script if it exists and isn't a shadowed script.
evalin('caller', [script ';']);
delete(cleaner);
댓글 수: 8
Rik
2019년 11월 19일
Can you confirm the m file name has an upper case h?
LUONG Vuong-son
2019년 11월 19일
KALYAN ACHARJYA
2019년 11월 19일
Done now??
LUONG Vuong-son
2019년 11월 19일
" nothing happens (no error). "
Are you sure your help.m file does something? Is it empty? Does it produce any outputs to the command window? produce a figure? How do you know it's not running?
If the file didn't exist or wasn't accessible you would get an error. For example:
>> run('C:\Users\name\Desktop\trash.m')
Error using run (line 68)
RUN cannot execute the file 'C:\Users\name\Desktop\trash.m'. RUN requires a valid MATLAB script
Put a break point at the top of your help.m file and run the code using your run() line.
Guillaume
2019년 11월 21일
What is the output of
which hello.m
- when your current directory is C:\users\ (i.e. when you're running the script from the editor)?
- when your current directory is whichever directory you're in when you're using the run command?
Are you sure that the actual script you're running is in C:\users\? This directory is not normally used to store matlab files and you shouldn't be putting files in there.
Does matlab tells you it needs to change directory when you run the script from the editor?
LUONG Vuong-son
2019년 11월 21일
Adam Danz
2019년 11월 21일
It was probably always working. For example, run this script and you'll see no evidence that it was executed.
t = 0;
x = t+9;
답변 (1개)
Jan
2019년 11월 21일
Store the M-files in a folder, in which you have full access. C:\Users\ is a bad idea. Create a folder somewhere else, e.g. inside your user folder, in the documents, on disk D, etc.
"Run function is always stubbed!" Is it? Then perhaps you have overwritten it? Check it:
which run -all
Check your script also:
which hello -all
type('C:\Users\hello.m') % Again: choose another folder
As said already, set a breakpoint in the code to check, if Matlab processes the assumed file at all.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!