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

📄 aaaa.f

📁 matlab从入门到精通第13章书后源码对初学者很有帮助
💻 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 + -