mexFunction input arguments - integer (used in mxCreateDoubleMatrix)
Show older comments
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 Comments
Jan
on 12 Nov 2012
"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
on 12 Nov 2012
James Tursa
on 13 Nov 2012
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.
Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!