| 查看: 596 | 回复: 0 | |||
aspenchen至尊木虫 (初入文坛)
|
[求助]
MATLAB调用Fortran代码mexfunction函数输出参数的个数是多个怎么搞?
|
|
#include "fintrf.h" subroutine mexfunction(nlhs,plhs,nrhs,prhs) integer::nlhs,nrhs mwpointer::plhs(*),prhs(*) integer::mxgetm,mxgetn mwpointer::mxCreateDoubleMatrix,mxgetpr integer::m(2),n(2) real*8,allocatable::a(:, ,b(:, ,c(:, ,d(:,![]() m(1)=mxgetm(prhs(1)) n(1)=mxgetn(prhs(1)) m(2)=mxgetm(prhs(2)) n(2)=mxgetn(prhs(2)) allocate(a(m(1),n(1)),b(m(2),n(2)),c(m(1),n(2))) call mxCopyPtrToReal8(mxgetpr(prhs(1)),a,m(1)*n(1)) call mxCopyPtrToReal8(mxgetpr(prhs(2)),b,m(2)*n(2)) plhs(1)=mxCreateDoubleMatrix(m(1),n(2),0) plhs(2)=mxCreateDoubleMatrix(m(1),n(1),0) c=matmul(a,b) d=2.0*a call mxcopyreal8toptr(c,mxgetpr(plhs(1)),m(1)*n(2)) call mxcopyreal8toptr(d,mxgetpr(plhs(2)),m(1)*n(1)) return end subroutine ==================================================== 上面这个例子要输入两个矩阵,求两个矩阵的乘积和第一个*2,然后输出两个结果,也就是nlhs应该是2,但是MATLAB运行直接跳错,请问有没有知道哪里错了的 |
» 猜你喜欢
化学求调剂
已经有5人回复
一志愿中国石油大学(华东) 本科齐鲁工业大学
已经有3人回复
332求调剂
已经有4人回复
265求调剂
已经有9人回复
328求调剂,英语六级551,有科研经历
已经有8人回复
求调剂
已经有3人回复
278求调剂
已经有6人回复
307求调剂
已经有10人回复
279分求调剂 一志愿211
已经有12人回复
297求调剂
已经有9人回复













,b(:,
回复此楼