How to resolve Undefined function or variable error?

Hi,
I had completed my project. That was working fine on another computer. When copied it on my laptop. It starts giving error on every function i defined. Giving "Undefined function or variable" error.
So how to resolve this issue? What is the possible solution for this cause?

8 comentarios

KSSV
KSSV el 12 de Dic. de 2018
Are both MATLAB versions same? Did you copy all the required functionns which your code uses?
Yes sir. Both matlab version are same. Also all required files are copied.
KSSV
KSSV el 12 de Dic. de 2018
The required files are in the same folder? Or if in different folder, are they added in path?
Same folder sir
KSSV
KSSV el 12 de Dic. de 2018
Can you show us the code? It should not show such errors..
Manzoor Hussain
Manzoor Hussain el 12 de Dic. de 2018
Editada: per isakson el 12 de Dic. de 2018
clc
clear
close all
% wfdb2mat('mitdb/100')
% save('Filter','BP_Filter');
dataset='106';
load Filter
% load 100m.mat
[Raw_ECG_Signal,Fs,tm]=rdsamp(dataset);
[ann, anntype]=rdann(dataset,'atr',[],108000);
% anntime=wfdbtime(dataset,ann);
Channel1_Raw_ECG=Raw_ECG_Signal(1:108000,1);
Filtered_Channel1=BP_Filter(Channel1_Raw_ECG);
[p,s,mu] = polyfit((1:numel(Filtered_Channel1))',Filtered_Channel1,20);
f_y = polyval(p,(1:numel(Filtered_Channel1))',[],mu);
Detrended_Channel1_ECG = Filtered_Channel1 - f_y; % Detrend data
Smoothed_Channel1=1.7.*smoothdata(Detrended_Channel1_ECG,'gaussian',20);
[~,loc]=findpeaks(Smoothed_Channel1,'MinPeakHeight',0.5,'MinPeakDistance',200);
for i=5:length(loc)-1
pd=Smoothed_Channel1(loc(i)-70:loc(i)+145);
fig=figure;
fig.Visible='off';
plot(pd)
axis off
fpname=strcat('C:\Users\SHIFAT GILLANI\Desktop\UMAIR\ECG\Normal\Img',num2str(i),'.tiff');
saveas(fig,fpname,'tiff')
figrsz=imresize(imread(fpname,'tiff'),[227 227]);
imwrite(figrsz,fpname,'tiff')
end
% TS = dsp.TimeScope('SampleRate',360,...
% 'TimeSpan',5,...
% 'YLimits',[-1 1],...
% 'ShowGrid',true,...
% 'NumInputPorts',3,...
% 'LayoutDimensions',[3 1],...
% 'TimeAxisLabels','Bottom',...
% 'Title','Noisy and Filtered Signals');
% tic;
% while toc<5
% toc
% TS(Channel1_Raw_ECG, Detrended_Channel1_ECG, Smoothed_Channel1);
% end
% release(TS)
wt = modwt(Smoothed_Channel1,5);
wtrec = zeros(size(wt));
wtrec(4:5,:) = wt(4:5,:);
y = imodwt(wtrec,'sym4');
y = abs(y).^2;
[~,locs] = findpeaks(y,'MinPeakHeight',0.35,'MinPeakDistance',200);
for i=1:length(locs)-1
hr(i)=60*(360/(locs(i+1)-locs(i)));
end
[a,b,c,d,e,f]=rdann(dataset,'atr');
Adam Danz
Adam Danz el 13 de Dic. de 2018
As mentioned above by others, one of the following circumstances is probably causing the error.
  1. You are missing a function.
  2. You are not missing a function but the function is not on the matlab path.
  3. You are missing an entire toolbox
  4. You're using a different version of matlab that lacks a function.
  5. Perhaps one version uses a global variable that isn't declared in the other version.
You provided your code but you didn't tell us what line is causing the error. If you include the full error message that will be helpful.
Walter Roberson
Walter Roberson el 13 de Dic. de 2018
Editada: Walter Roberson el 13 de Dic. de 2018
It starts giving error on every function i defined
The location you copied the files into is not your current directory and is not on your MATLAB path. Use pathtool to add the directory to your path.
There is one other alternative: you might have defined the functions with a file name in a different case (upper / lower case) than the name of the function, and the file system you were using originally was not case sensitive, but the new file system is case sensitive. For example NTFS filesystems are not typically set to be case sensitive, so RDsamp.m would be considered the same file as rdsamp.m, but Linux filesystems usually are case sensitive, so RDsamp.m would not be looked for when looking for function rdsamp

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Preguntada:

el 12 de Dic. de 2018

Editada:

el 13 de Dic. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by