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 件のコメント

KSSV
KSSV 2018 年 12 月 12 日
Are both MATLAB versions same? Did you copy all the required functionns which your code uses?
Manzoor Hussain
Manzoor Hussain 2018 年 12 月 12 日
Yes sir. Both matlab version are same. Also all required files are copied.
KSSV
KSSV 2018 年 12 月 12 日
The required files are in the same folder? Or if in different folder, are they added in path?
Manzoor Hussain
Manzoor Hussain 2018 年 12 月 12 日
Same folder sir
KSSV
KSSV 2018 年 12 月 12 日
Can you show us the code? It should not show such errors..
Manzoor Hussain
Manzoor Hussain 2018 年 12 月 12 日
編集済み: per isakson 2018 年 12 月 12 日
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 2018 年 12 月 13 日
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 2018 年 12 月 13 日
編集済み: Walter Roberson 2018 年 12 月 13 日
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

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

質問済み:

2018 年 12 月 12 日

編集済み:

2018 年 12 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by