Mex mxGetField do loop
Show older comments
Hello,
I'm trying to use a do loop in my mex function that will take the values passed via a struct form from matlab. The matlab struct is as follows:
TurbineComponents.Blade(1).Position = ...
TurbineComponents.Blade(1).Orientation = ...
etc
I try the following as my do loop in the mex file:
Do J = 1, NumBl
Blade1_pr = mxGetField(prhs(ArgNum),1,'Blade(J)')
b1p_pr = mxGetField(Blade1_pr,1,'Position')
b1p_ptr = mxGetPr(b1p_pr)
b1o_pr = mxGetField(Blade1_pr,1,'Orientation')
b1o_ptr = mxGetPr(b1o_pr)
b1v_pr = mxGetField(Blade1_pr,1,'RotationVel')
b1v_ptr = mxGetPr(b1v_pr)
b1t_pr = mxGetField(Blade1_pr,1,'TranslationVel')
b1t_ptr = mxGetPr(b1t_pr)
call mxcopyptrtoreal8(b1p_ptr,TurbineComponents%Blade(J)%Position,size2)
call mxcopyptrtoreal8(b1o_ptr,TurbineComponents%Blade(J)%Orientation,size3)
call mxcopyptrtoreal8(b1v_ptr,TurbineComponents%Blade(J)%RotationVel,size2)
call mxcopyptrtoreal8(b1t_ptr,TurbineComponents%Blade(J)%TranslationVel,size2)
end Do
The problem is coming from the first line of code, "Blade(J)" I believe. Is there a way to work around the field name?
Accepted Answer
More Answers (0)
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!