'eval' works on one computer but not on the other....

4 ビュー (過去 30 日間)
Chris E.
Chris E. 2012 年 11 月 12 日
編集済み: per isakson 2017 年 2 月 16 日
I have 2 computers, both with windows 7 and both with the 7.10.0 version of MATLAB, both have identical MATLAB programs I created.
I am using the "eval" function in MATLAB and evaluating a address of something like (both computers):
eval([cd C:\Users\Documents\Images\Scan1]);
One computer this works, but the on the other computer it does not work. The one computer that does not works says,
"Error using ==> cd
Too many input arguments."
The one that works does not have this issue at all and works fine, exactly as I intended. I'm really at a loss to enplane or fix why one works and the other does not when they are nearly identical operating systems, MATLAB versions and MATLAB programs. Please help! Thanks, Chris
  1 件のコメント
Jan
Jan 2012 年 11 月 13 日
@Chris: Please search in this forum for "eval". You will find hundreds of suggestions to avoid this function, because it causes more problems than it solves.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2012 年 11 月 12 日
Are there spaces in any of the directory names in the path you're cd-ing to? What happens when you just use cd without eval? In fact, why use eval at all? Why not just do
cd(mypath)
  1 件のコメント
Chris E.
Chris E. 2012 年 11 月 12 日
Thank you this worked! Chris

サインインしてコメントする。

その他の回答 (1 件)

Matt Fig
Matt Fig 2012 年 11 月 12 日
編集済み: Matt Fig 2012 年 11 月 12 日
On the computer where it does not work, do this:
which cd
See if someone has saved a script named cd that is masking the built-in function. And why are you using EVAL for this purpose anyway?? The command will work without putting it inside EVAL...
cd C:\Users
is the same as:
eval('cd C:\Users')

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by