⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matlabeng.f90

📁 fortran 调用matlab引擎实例
💻 F90
字号:
program main
integer engOpen,engGetMatrix,mxCreateFull,mxGetPr
integer ep,T,D,result
double precision time(10),dist(10)
integer stat,temp
data time/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0/
ep=engOpen('matlab')
if(ep.eq.0)then
	print*,'Can''t start MATLAB engine'
	stop
endif
T=mxCreateFull(1,10,0)
call mxSetName(T,'T')
call mxCopyReal8ToPtr(time,mxGetPr(T),10)
call engPutMatrix(ep,T)
call engEvalString(ep,'D=.5.*(-9.8).*T.^2;')
call engEvalString(ep,'plot(T,D);')
call engEvalString(ep,'title("position---time")')
call engEvalString(ep,'xlabel("time(second)")')
call engEvalString(ep,'yabel("position(meter)")')
print*,'Type 0 <return> to Exit'
print*,'Type 1 <return> to Continue'
read*,temp
if(temp.eq.0) then
	print*,'EXIT!'
	stop
endif

call engEvalString(ep,'close;')
D=engGetMatrix(ep,'D')
call mxCopyPtrToReal8(mxGetPr(D),dist,10)
print*,'MATLAB computed the following distance:'
print*,'time(s) distance(m)'
do i=1,10
	print 20,time(i),dist(i)
20	format('',G10.3,G10.3)
enddo
call mxFreeMatrix(T)
call mxFreeMatrix(result)
stat=engClose(ep)
stop
end
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -