Error while evaluating uicontrol Callback
6 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Geoff Hayes
on 19 Jan 2017
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 Comments
More Answers (1)
See Also
Categories
Find more on Printing and Saving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!