Unexpected MATLAB operator when using fully qualified path name

I'd like to specify a fully qualified path name as input to Matlab on Linux, but it doesn't seem to accept it. The file is
% cat hw.m
msg='hello, world'
From the Matlab prompt, anything other than the basename causes an error. Is there a way to make this work?
>> /home/matlab/hw
/home/matlab/hw
|
Error: Unexpected MATLAB operator.
>> ~/matlab/hw
~/matlab/hw
|
Error: Unexpected MATLAB operator.
>> ./hw
./hw
|
Error: Unexpected MATLAB operator.
>> hw
msg =
hello, world

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 23일
편집: Azzi Abdelmalek 2015년 7월 23일
You have forgotten the quotes
'/home/matlab/hw'

댓글 수: 1

Thanks, that works from the Matlab prompt. It looks like I have to escape it from the command line:
% matlab -nodisplay -nosplash -r \'/home/matlab/hw\'

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by