[Help] Undefined function or variable 'Reference'. On Running a .m script file.

1 回表示 (過去 30 日間)
Waqar Ali Memon
Waqar Ali Memon 2019 年 7 月 31 日
コメント済み: Waqar Ali Memon 2019 年 7 月 31 日
Hello Everyone,
While running a .mat file I am incurring the following error:
Undefined function or variable 'Reference'.
But when i select all the code and press evaluate section, it executes the code.
Can any one guide me, how to overcome this? and why this happens?
This is how my .mat file starts:
%% Reference_Project: Excel List
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% Function: Getting a Unique list.
% Filename: List.m
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%%
clear;
clc;
disp('Starting the Program, Please click on Next and Finish (if it appears).');
warning off;
%% Selects the Current Directory and Imports all the files with .xls extension.
% % Note: .xls files and this code should be in same folder.
myDir = uigetdir; %Gets the current directory
myFiles = dir(fullfile(myDir,'*.xls')); %Gets all .xls files in structure
fileNames = {myFiles.name}; % to convert the name of files in string format
for k = 1:numel(fileNames) % running a loop from 1 till number of files
data{k} = uiimport(fileNames{k}); % importing k number of files
%%do whatever you want
end
Any help would be appreciated :-).
Regard,s
Waqar Ali
  7 件のコメント
Fangjun Jiang
Fangjun Jiang 2019 年 7 月 31 日
Don't use minus (-) in the M-file name. Instead, use underscore (_).
Waqar Ali Memon
Waqar Ali Memon 2019 年 7 月 31 日
Thank you Fangjun Jiang,
It work now :-)

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

採用された回答

Alex Mcaulley
Alex Mcaulley 2019 年 7 月 31 日
The name of your script "Reference-EPD-Project-v4" is not a valid name for a function/script. Are you sure that this is the name? If it is the case, change the name of the file to a valid name (i.e. "Reference_EPD_Project_v4").
  1 件のコメント
Waqar Ali Memon
Waqar Ali Memon 2019 年 7 月 31 日
Thank you Alex Mcaulley,
yes the name was correct. Replacing - with _ works.
Thanks :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by