Cannot open file for reading when using system()

4 ビュー (過去 30 日間)
Thomas Weaver
Thomas Weaver 2020 年 9 月 11 日
編集済み: Mario Malic 2020 年 9 月 11 日
I have two files in a directory, 'test01.model' and 'test02.model'. These files are used as input into a Windows executable program. My code uses the system command to run the .exe program with each file and obtain the results. As an example, I use the following code.
sysInput = 'C:\geopsypack-win10-3.3.1\bin\gpdc.exe test01.model'
[status, result] = system(sysInput, '-echo');
Everything works fine for 'test01.model.
When I change sysInput to:
sysInput = 'C:\geopsypack-win10-3.3.1\bin\gpdc.exe test02.model'
I get the following message: 'Cannot open file 'test02.model' for reading'.
If I use the ! command as follows
!C:\geopsypack-win10-3.3.1\bin\gpdc.exe < test02.model
The following is returned: 'The system cannot find the file specified.'
I have used the exist command as follows:
exist('C:\geopsypack-win10-3.3.1\bin\test02.model')
A value of 2 is returned, so the file does exist.
When I open up a poweshell in the directory where 'gpdc.exe' and 'test02.model' are located, I can run the program from the command line with 'test02.model' and obtain results. I made a copy of 'test01.model' and renamed it to 'test02.model' and still have the same problem.
What can I do so that 'test02.model' can be used as input to my .exe program using MATLAB?
  2 件のコメント
Mario Malic
Mario Malic 2020 年 9 月 11 日
編集済み: Mario Malic 2020 年 9 月 11 日
I have just moved the comment to answer as it helped, so we can close the question and get a rep point.
Thomas Weaver
Thomas Weaver 2020 年 9 月 11 日
That worked. Thanks!!

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

採用された回答

Mario Malic
Mario Malic 2020 年 9 月 11 日
Supply fullpath to model file instead.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEigenvalue Problems についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by