Search code examples
matlabsmoothing

Unrecognized function or variable 'dip_filtering'


I am getting the following error message in Matlab:

Unrecognized function or variable 'dip_filtering'

when I run this code that should display a smoothened line of data with x and y coordinates.

k=5;
 
PEAKSx = [];
PEAKSy = [];
 
 
for i=[15, 16]  
   
myfile=['exp' num2str(i)  '.txt'];
mimat=dlmread(myfile,'',1,0);
eval(['exp' num2str(i) ' = mimat;']);
clear myfile mimat1 
 
matrix=sprintf('exp%0.0f',i);   
eval(sprintf('temp_data = %s;', matrix));
 
tempdata_2=smooth(temp_data(:,2),5,'moving');
tempdata_1=smooth(temp_data(:,1),5,'moving');
 
cc=hsv(10); 
 
[cPeaks,vPeaks,w,p] = findpeaks(tempdata_1,tempdata_2,'MinPeakProminence',(5*10^-9));
 
PEAKSx = [PEAKSx; vPeaks];
PEAKSy = [PEAKSy; cPeaks];
 
plot(tempdata_2(:,1),1e9*tempdata_1(:,1))
 
hold on
xlabel('E_{app} / V','fontsize',11,'fontweight','bold'); 
ylabel('I / nA','fontsize',11,'fontweight','bold');
 
end
disp('x-values y-values')
[PEAKSx PEAKSy*10^9]

The error happens when this line is called:

tempdata_2=smooth(temp_data(:,2),5,'moving');

The smooth function calls this function:

function out = smooth(varargin)
out = gaussf(varargin{:});

which in turn calls the gaussf function:

function image_out = gaussf(image_in,sigma,method,varargin)
% The code below looks a little silly, but it's an easy way to not parse input arguments twice.
if nargin < 2
   image_out = dip_filtering('derivative',image_in);
elseif nargin < 3
   image_out = dip_filtering('derivative',image_in,0,sigma);
else
   if ~ischar(method) && ~isvector(method)
      error('METHOD argument must be a string');
   end
   if ~strcmp(method,'best') && ~strcmp(method,'kernel')
      method = ['gauss',method];
   end
   image_out = dip_filtering('derivative',image_in,0,sigma,method,varargin{:});
end

Both the smooth and gauss functions seem to be built in or may have come with some standard add in packages.
I cannot find anything related to matlab and 'dip_filtering' while making a google search.


Solution

  • The smooth and gaussf functions come from the DIPimage toolbox, which seems to not be correctly installed on your system.

    You can find installation packages here: https://github.com/DIPlib/diplib/releases

    You can find installation instructions here: https://diplib.org/diplib-docs/sec_dum_installing.html

    This is the project home page: https://diplib.org/.