📄 aaaa.f
字号:
subroutine test(x,y,z,out1,out2)
real *8 x,y,z,out1,out2
out1=x+y+z
out2=x*y*z
return
end
subroutine mexfunction(nlhs,plhs,nrhs,prhs)
integer plhs(*),prhs(*)
integer xp,yp,zp,pout1,pout2
integer nlhs,nrhs,m,n,size
integer mxGetPr,mxCopyPtrTo,mxCreateFull
integer mxGetM,mxGetN
real *8 x,y,z,out1,out2
if (nlhs.ne.2) then
call mexerrmsgtxt('require 2 output arg')
endif
if (nrhs.ne.3) then
call mexerrmsgtxt('require 3 input arg')
endif
m=mxGetM(prhs(1))
n=mxGetN(prhs(1))
size=m*n
plhs(1)=mxCreateFull(m,n,0)
plhs(2)=mxCreateFull(m,n,0)
xp=mxGetPr(prhs(1))
yp=mxGetPr(prhs(2))
zp=mxGetpr(prhs(3))
call mxcopyptrtoreal8(xp,x,size)
call mxcopyptrtoreal8(yp,y,size)
call mxcopyptrtoreal8(zp,z,size)
pout1=mxGetPr(plhs(1))
pout2=mxGetPr(plhs(2))
call test(x,y,z,out1,out2)
call mxcopyreal8toptr(out1,pout1,size)
call mxcopyreal8toptr(out2,pout2,size)
return
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -