Error while evaluating uicontrol Callback
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi everybody. My problem is about programmed GUI when I press the push button on the calculator.
function BrowseFile_Callback(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.txt','Select the txt file');
if PathName ~= 0 %if user not select cancel
PathNameFileName = [PathName FileName];
set(handles.filepath, 'string',PathNameFileName);
%PathName = get(handles.filepath, 'string');
addpath(PathName); %add path to file search
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%reading the color matching functions
data = csvread('ciexyz31_1.csv');
wavelength = data(:,1);
redCMF = data(:,2);
greenCMF = data(:,3);
blueCMF = data(:,4);
%plot(wavelength,redCMF);
% readint the PL data
fid = fopen(FileName, 'r');
%PLdata = fscanf(fid, '%g %g', [2 inf]); % It has two rows now.
hl = str2num(get(handles.headerline,'string'));
PLdata = textscan(fid,'%f %f','HeaderLines',hl);
%PLdata = dlmread(FileName, '', 40, 1) %matrix = dlmread(filename, delimiter, firstRow, firstColumn)
fclose(fid)
% PLwavelength = PLdata(1,:);
% PLIntensity = PLdata(2,:);
PLwavelength = PLdata{1,1};
PLIntensity = PLdata{1,2};
plot(handles.PLdataaxis,PLwavelength,PLIntensity);
end
Can anyone help me on this problem? Thanks.
댓글 수: 0
채택된 답변
Geoff Hayes
2017년 1월 19일
Diem - your above code is incomplete as the error message is referencing code that does not exist in what you have copied and pasted into your question
??? Undefined function or variable 'wave'
Error in BrowseFile_Callback
handles.X = trapz(wave, CIEXydata);
etc.
The error message is telling you that you are trying to use a variable that has yet to be defined. Ensure that exists before trying to use it. If you are using global variables, then I recommend that you store these "globals" to the handles structure so that they are available in all callbacks.
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!