mexFunction input arguments - integer (used in mxCreateDoubleMatrix)
显示 更早的评论
Hi,
i want to use, integer mexFunktion input arguments to scale a a matrix:
% code
row = 1
call mxCopyPtrToInteger4(il_pr,il,row)
call mxCopyPtrToInteger4(iq_pr,iq,row)
ilq = (il-1)*(iq-1)
plhs(1) = mxCreateDoubleMatrix(ilq,1,0)
scoop dec.
mwPointer iq_pr, il_pr
mwSize ilq, row
integer*4 il, iq
il_pr and iq_pr are related to prhs(3) and prhs(4)
Output is allways a 1x1 Matrix.
But everything works fine when ilq is set manually to e.g. 50. Then the Matrix is 50x1.
I got the same problem if i use il instead of ilq in the mxCreateDoubleMatrix()
I would be glad if someone has some ideas.
kind regards
Alex
I use Matlab R2012b (Mac 64bit) and gcc gfortran 4.6
6 个评论
Jan
2012-11-12
"Output is allways a 1x1 Matrix.": is this wanted or not wanted? What exactly is the question? How do you set "ilg manually to 50"? What is the contents of ilq, when you assign the value "not manaully"?
On 64 bit machines, mxCreateDoubleMatrix expects 64 bit integers for the dimensions.
Is it your intentation that iq is overwritten in the 2nd line, while il is undefined?
call mxCopyPtrToInteger4(il_pr,iq,row)
call mxCopyPtrToInteger4(iq_pr,iq,row)
Alexander
2012-11-12
James Tursa
2012-11-13
I would say this is a poor way to go about things. Requiring the input to be int32 puts unnecessary restrictions on your mex code and it will not be robust. I would advise looking into using mxGetScalar instead.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!