主题:通过matlab调用Fortran可执行文件读外部文本
问题描述:通过matlab调用visual Fortran 9.0生成的.exe文件读取外部文本
其中MATLAB中的.m文件的内容为
----------------------------------------
name = {'t1.dat','t2.dat','t3.dat'};
batch = 'test.exe';
for i = 1:length(name)
batch = strcat(batch,{' '},name{i});
end
batch{1}
dos(batch{1});
----------------------------------------
其中t1.dat,t2.dat,t3.dat中分别只有一个整数1,2,3,test.exe文件为Fortran可执行文件,其中代码为
test.f90
-------------------------------------
implicit none
integer i
open(1,file = ' ',status = 'old')
read(1,*) i
close(1)
print*,i
open(1,file = ' ',status = 'old')
read(1,*) i
close(1)
print*,i
open(1,file = ' ',status = 'old')
read(1,*) i
close(1)
print*,i
pause
end
---------------------------------------
将上面的.m文件,三个文本文件,test.exe文件放在同一文件夹中
在matlab界面下进入该文件夹并运行.m文件,出线如下错误:
----------------------------------------------------------------------
forrtl: severe (29): file not found, unit 1, file
Image PC Routine Line Source
test.exe 00497692 Unknown Unknown Unknown
test.exe 0049492C Unknown Unknown Unknown
test.exe 0040BF02 Unknown Unknown Unknown
test.exe 0040BB1F Unknown Unknown Unknown
test.exe 00401FE9 Unknown Unknown Unknown
test.exe 0040106A _MAIN__ 3 test.F90
test.exe 0049DDEC Unknown Unknown Unknown
test.exe 0043DFA3 Unknown Unknown Unknown
test.exe 0043DD6D Unknown Unknown Unknown
kernel32.dll 7C817067 Unknown Unknown Unknown
-----------------------------------------------------------------------
不知道是什么原因导致这样的问题,请各位大侠指点迷津!
其中MATLAB中的.m文件的内容为
----------------------------------------
name = {'t1.dat','t2.dat','t3.dat'};
batch = 'test.exe';
for i = 1:length(name)
batch = strcat(batch,{' '},name{i});
end
batch{1}
dos(batch{1});
----------------------------------------
其中t1.dat,t2.dat,t3.dat中分别只有一个整数1,2,3,test.exe文件为Fortran可执行文件,其中代码为
test.f90
-------------------------------------
implicit none
integer i
open(1,file = ' ',status = 'old')
read(1,*) i
close(1)
print*,i
open(1,file = ' ',status = 'old')
read(1,*) i
close(1)
print*,i
open(1,file = ' ',status = 'old')
read(1,*) i
close(1)
print*,i
pause
end
---------------------------------------
将上面的.m文件,三个文本文件,test.exe文件放在同一文件夹中
在matlab界面下进入该文件夹并运行.m文件,出线如下错误:
----------------------------------------------------------------------
forrtl: severe (29): file not found, unit 1, file
Image PC Routine Line Source
test.exe 00497692 Unknown Unknown Unknown
test.exe 0049492C Unknown Unknown Unknown
test.exe 0040BF02 Unknown Unknown Unknown
test.exe 0040BB1F Unknown Unknown Unknown
test.exe 00401FE9 Unknown Unknown Unknown
test.exe 0040106A _MAIN__ 3 test.F90
test.exe 0049DDEC Unknown Unknown Unknown
test.exe 0043DFA3 Unknown Unknown Unknown
test.exe 0043DD6D Unknown Unknown Unknown
kernel32.dll 7C817067 Unknown Unknown Unknown
-----------------------------------------------------------------------
不知道是什么原因导致这样的问题,请各位大侠指点迷津!