Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: m-code and c++_mex code conversion
Replies: 2   Last Post: Aug 7, 2013 9:14 PM

 Messages: [ Previous | Next ]
 Kate Posts: 90 Registered: 8/28/10
m-code and c++_mex code conversion
Posted: Aug 7, 2013 3:10 PM

Hello all,

I have a simple Matlab function I want to convert to MEX. But I am having some errors in the MEX code I attempted. Below are links to the working Matlab function & my attempt at coding a MEX-version of it. Any help in getting a working MEX-script appreciated, -thanks.

Matlab function is at :

Mex-attempt verison of original function at:

To run the code, here is a script with data which works with the Matlab function:

clc;clear all;close all
beep off
format long
data1 = [0.020167 -0.018696 0.136442
0.027073 0.047748 0.121732
0.022645 0.063994 0.113459
0.025322 0.055569 0.121202
0.025322 0.055569 0.121202

];

data2 = [0.004491 -0.004283 0.139417
0.011341 0.077656 0.116881
0.022994 0.050471 0.139951
0.006699 0.018414 0.138197
];

x1 = data1(:,1);
y1 = data1(:,2);
z1 = data1(:,3);

x2 = data2(:,1);
y2 = data2(:,2);
z2 = data2(:,3);

%----- parameters ------%
sigma_p2 =0.01;
sigma_inf = 0.00001;
sigma_factor = 0.9;
d_02 = 0.01;
%-----------------------%

h_R = [1 0 0 ; 0 1 0 ; 0 0 1];
h_t = [0 0 0];
rowsA = size(x2,1);
colsA = size(x1,1);
h_one = ones(colsA,1);

h_Xx = x1;
h_Xy = y1;
h_Xz = z1;

h_X = [h_Xx h_Xy h_Xz];

h_Yx = x2;
h_Yy = y2;
h_Yz = z2;

h_Y = [h_Yx h_Yy h_Yz];

pitchA = floor(rowsA/4 + 1) *4;

[h_A ]=update_A_testing(h_Xx,h_Xy,h_Xz,h_Yx,h_Yy,h_Yz,colsA,rowsA,h_R,h_t,sigma_p2,pitchA)

Date Subject Author
8/7/13 Kate
8/7/13 Kate
8/7/13 Kate