Mex function, one or more output arguments not assigned

5 views (last 30 days)
Hello,
I get the following error when trying to test my mex function "One or more output arguments not assigned during call to 'mymexfunction'". There should be 102 outputs from the function.
I do the following to copy the variables from the fortran code back to matlab
plhs(1) = mxcreatedoublematrix(m2,n2,0)
plhs(2) = mxcreatedoublematrix(m2,n2,0)
plhs(3) = mxcreatedoublematrix(m2,n2,0)
etc...
MRb1_1p_pr = mxgetpr(plhs(1))
MRb1_2p_pr = mxgetpr(plhs(2))
MRb1_3p_pr = mxgetpr(plhs(3))
etc...
call mxcopyreal8toptr(MarkersResults%Blade(1,1)%Position,MRb1_1p_pr,size2)
call mxcopyreal8toptr(MarkersResults%Blade(2,1)%Position,MRb1_2p_pr,size2)
call mxcopyreal8toptr(MarkersResults%Blade(3,1)%Position,MRb1_3p_pr,size2)
etc...
I try to get the results using the following syntax in my .m file
%[M1, M2, M3, etc..] = mymexfunction(var1, var2)

Answers (1)

James Tursa
James Tursa on 23 Jul 2012
102 outputs is a LOT, and seems to me would be hard to maintain. Returning a single cell array would probably be a better approach.
That being said, I am not sure what the internal limit is for this. I know mexCallMATLAB has an internal limit of 50. There may be a similar limit for the plhs array. But assuming this is not an issue, do you really have 102 statements creating outpus from plhs(1) all the way through plhs(102)? Are these all behind some type of "if" check to make sure nlhs == 102? Are you sure you have 102 outputs in your m-file calling sequence?
  5 Comments
Chris
Chris on 24 Jul 2012
Also is there a limit to the number of inputs you can have? If I have a nested struct for an input for a total of over a 100 inputs would that be a problem?
Chris
Chris on 6 Aug 2012
Hi James,
Were you able to write a code that returns a struct array? I'm still stuck on this part of the project.

Sign in to comment.

Categories

Find more on Fortran with MATLAB 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!