2017-05-08 63 views
0

我正在使用調用與mex文件關聯的函數的Matlab代碼(它們具有相同的名詞)。但是,我收到一個錯誤,指出該函數未定義。未關聯的函數與mex文件相關聯

在我調用此函數之前,我應該執行指定的命令嗎? (我正在使用MAC OS X和Matlab R 2016a)。

下面是代碼,錯誤是在該行調用函數fastmarchmex(我記得fastmarchmex.mexw64和32是在當前文件夾):

rootdir = fileparts(mfilename('fullpath')); 
addpath(fullfile(rootdir,'util')); 
addpath(fullfile(rootdir,'sihks')); 

load(fullfile(rootdir,'shapes','0001.scale.1.mat'),'shape' 
%%-------------------------------------------------------------------  
%% SIHKS signature 
%%------------------------------------------------------------------- 
fprintf('preprocessing'); 
shape.idxs = compute_vertex_face_ring(shape.TRIV'); 
ndesc   = 5; 
[desc,shape] = signature(shape,'sihks'); 
fprintf('.'); 

%%------------------------------------------------------------------- 
%% ISC settings 
%%------------------------------------------------------------------- 

rad  = 10; % radius used for descriptor construction 
nbinsr = 5; % number of rings 
nbinsth = 16; % number of rays 

rr  = [1:nbinsr]/nbinsr*rad; 
th  = [1:nbinsth]/nbinsth*2*pi; 

fhs  = 2;   %% factor determining hardness of scale 
quantization 

fha  = .01;  %% factors determining hardness of angle 
quantization 

**shape.f_dns  = fastmarchmex('init', int32(shape.TRIV-1),   
double(shape.X(:)), double(shape.Y(:)), double(shape.Z(:)));** 

vertex        = 701; 
shape         = 
fast_marching(vertex,shape,'vertex',0,1,shape.f_dns); 

[in_ray,in_ring,shp,geod,directions]= get_net(shape,vertex,'scales', 
[0,rr],'N_rays',length(th),'fhs',fhs,'fha',fha); 

[dec_net] = get_descriptor_from_net(in_ray,in_ring,desc,shape.Av); 
fastmarchmex('deinit', shape.f_dns); 


%% end of code, visualization of results 
a = -82.5000; 
v = 18; 

dind = 1; 
figure(1); clf; show_shape(shape,desc(:,dind)); 
hold on,scatter3(geod{1}(1,1),geod{1}(2,1),geod{1} 
(3,1),'filled','SizeData',150,'Cdata',[1,0,0]) 

for k=[1:length(geod)] 
    hold on; 
    h = plot3(geod{k}(1,:),geod{k}(2,:),geod{k}(3,:)); 
    set(h,'Color',[0 0 0],'LineWidth',2); 
end 
for r = [1:length(rr)] 
    plot_ring(shape,rr(r)); 
end 
title('Net around vertex') 
view(-82.50,18) 

figure(2); clf; plot_polarhist(squeeze(desc_net(dind,:,:)),rr,th,0); 
+0

函數和mex文件在你的[工作目錄](https://mathworks.com/help/matlab/ref/pwd.html)或你的[path ](https://mathworks.com/help/matlab/ref/path.html)? – codeaviator

+0

當然他們是 –

+0

調用與mex文件(functionAmex.mexw64)關聯的函數(functionA)的file.m位於相同的當前文件夾中 –

回答

0

MATLAB R13 and later, which support Mac OS X, use the .mexmac extension on the Mac. 所以,你應該重新編譯你的Mex文件爲Mac現在你有Windows版本

+0

我沒有生成mex文件的源代碼。我將切換到Linux,看看它是否有效。謝謝! –

+0

你應該嘗試Windows。這些Mex文件是針對此操作系統編譯的 – zlon

+0

在Linux Ubuntu上,我收到了以下錯誤:未定義的函數'fastmarchmex'用於'int64'類型的輸入參數。這看起來很奇怪,因爲我的目錄中有fastmarchmex.mexw64和fastmarchmex.mexw32 –