2017-04-18 101 views
0

我最近從matlab網站下載了一些代碼來運行八度。當我嘗試運行我創建一個test.m文件從下載源代碼文件調用幾個功能我得到:刪除matlab版本檢查代碼

octave:2> test

error: `verLessThan' undefined near line 101 column 8

error: called from:

error: /media/34GB/escola/efficientLBP/assignUserInputs.m at line 101, column 5

error: /media/34GB/escola/efficientLBP/efficientLBP.m at line 113, column 1

error: /media/34GB/escola/efficientLBP/test.m at line 5, column 7

檢查源文件,我發現這個代碼

if isempty(funcParamsNames) 
     isNoFuncParamsNames=true; 
    else 
     if verLessThan('matlab', '7.14') % again, old version do not support 'stable'. 
      funcParamsNames=unique(funcParamsNames); % This can lead to bugs :(
     else 
      funcParamsNames=unique(funcParamsNames , 'stable'); 
     end% 
     isNoFuncParamsNames=false; 
    end 

所以我想知道是否有一種方法可以讓八度音程來識別這個功能。 謝謝你的時間。

+0

倍頻的'unique'像Matlab的'唯一的(..., '排序')',而不是像'唯一的(... 'stable')',正如你可以看到[這裏](https://tio.run/nexus/octave#@[email protected]//8DAA)。如果你需要一個''stable'來進行Octave版本檢查[this ](https://github.com/lmendo/MATL/blob/master/compatibility/unique_comp.m) –

回答

0

Octave似乎知道一個等效函數unique,但是,我看不到像Matlabs 'stable'這樣的選項。

嘗試獨特,看看它是什麼我猜?

if isempty(funcParamsNames) 
    isNoFuncParamsNames=true; 
else 
    funcParamsNames=unique(funcParamsNames);  
    isNoFuncParamsNames=false; 
end 
+0

謝謝弗洛裏安,這顯然解決了這個問題。 – user2752471

+0

不客氣! – Florian

0

你可以做unique'stable'自己:

x = rand(1,10);x(5) = x(1); 
% if you have 'stable' 
y1 = unique(x,'stable'); 
% if you don't have 'stable' 
[y2,ia] = unique(x); 
[ia,idxs] = sort(ia); 
y2 = y2(idxs); 
% compare 
isequal(y1,y2)