Help with Mex function
Show older comments
Hello, I'm having trouble getting a mex function to work. I think I've narrowed down the problem but anytime I try to fix anything Matlab shuts down.
I want to send a nested struct through a mex file myvar.myfield.mysubfield, where subfield is a 3-d position vector. I want to do mymexfunc(myvar).
mwPointer mxGetField
mwPointer mxGetPr
mwPointer mxcreatedoublematrix
mwIndex index
mwpointer var_ptr, fd_ptr, sfd_ptr
var_ptr = mxgetpr(prhs(1))
fd_ptr = mxgetfield(var_ptr,1,'myfield')
sfd_ptr = mxgetfield(fd_ptr,1,'mysubfield')
myvar%myfield%mysubfield = fpgetpr(sfd_ptr)
copy mxcopyptrtoreal8(sfd_ptr,myvar%myfield%mysubfield,size)
Matlab crashes when I try to do this and I wanted to know if anyone can see what I'm doing wrong.
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!