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!