0

I'm getting this unwanted parse error saying

Error: File: GUI.m Line: 284 Column: 5. Unexpected MATLAB operator.

However, I cannot see any unexpected operator. Can anybody diagnose this issue?

Here's my code:

function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
%      GUI, by itself, creates a new GUI or raises the existing
%      singleton*.
%
%      H = GUI returns the handle to a new GUI or the handle to
%      the existing singleton*.
%
%      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI.M with the given input arguments.
%
%      GUI('Property','Value',...) creates a new GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUI

% Last Modified by GUIDE v2.5 24-May-2017 23:28:18

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
end
% End initialization code - DO NOT EDIT


% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GUI (see VARARGIN)

% Choose default command line output for GUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = GUI_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in START.
function START_Callback(hObject, eventdata, handles)
% hObject    handle to START (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


global Cfilename;
global Cpathname;
global Tfilename;
global Tpathname;

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

tline = fgetl(fid);
C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});
Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tfilename = C{1,2};

Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

X = strsplit(C{1,1},{'-','.'});

global I;
global J;

I = X{1};
J = X{2};


function fname_Callback(hObject, eventdata, handles)
% hObject    handle to fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of fname as text
%        str2double(get(hObject,'String')) returns contents of fname as a double


% --- Executes during object creation, after setting all properties.
function fname_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function shaColor_Callback(hObject, eventdata, handles)
% hObject    handle to shaColor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of shaColor as text
%        str2double(get(hObject,'String')) returns contents of shaColor as a double


% --- Executes during object creation, after setting all properties.
function shaColor_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shaColor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function char_Callback(hObject, eventdata, handles)
% hObject    handle to char (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of char as text
%        str2double(get(hObject,'String')) returns contents of char as a double


% --- Executes during object creation, after setting all properties.
function char_CreateFcn(hObject, eventdata, handles)
% hObject    handle to char (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function charCol_Callback(hObject, eventdata, handles)
% hObject    handle to charCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of charCol as text
%        str2double(get(hObject,'String')) returns contents of charCol as a double


% --- Executes during object creation, after setting all properties.
function charCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to charCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function GLat_Callback(hObject, eventdata, handles)
% hObject    handle to GLat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of  GLat as text
%        str2double(get(hObject,'String')) returns contents of GLat as a double


% --- Executes during object creation, after setting all properties.
function GLat_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GLat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function GLong_Callback(hObject, eventdata, handles)
% hObject    handle to GLong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GLong as text
%        str2double(get(hObject,'String')) returns contents of GLong as a double


% --- Executes during object creation, after setting all properties.
function GLong_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GLong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
end
set(hObject,'BackgroundColor','white');


function shape_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shape (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function Orient_Callback(hObject, eventdata, handles)
% hObject    handle to Orient (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Orient as text
%        str2double(get(hObject,'String')) returns contents of Orient as a double

function Orient_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Orient (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
     set(hObject,'BackgroundColor','white');
 end


% --- Executes during object creation, after setting all properties.


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in CANCEL.
function CANCEL_Callback(hObject, eventdata, handles)
% hObject    handle to CANCEL (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function gLat2_Callback(hObject, eventdata, handles)
% hObject    handle to gLat2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of gLat2 as text
%        str2double(get(hObject,'String')) returns contents of gLat2 as a double


% --- Executes during object creation, after setting all properties.
function gLat2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gLat2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function gAlt_Callback(hObject, eventdata, handles)
% hObject    handle to gAlt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of gAlt as text
%        str2double(get(hObject,'String')) returns contents of gAlt as a double


% --- Executes during object creation, after setting all properties.
function gAlt_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gAlt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double


% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function GBear_Callback(hObject, eventdata, handles)
% hObject    handle to GBear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GBear as text
%        str2double(get(hObject,'String')) returns contents of GBear as a double


% --- Executes during object creation, after setting all properties.
function GBear_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GBear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in NEXT.
function NEXT_Callback(hObject, eventdata, handles)
% hObject    handle to NEXT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function shape_Callback(hObject, eventdata, handles)
% hObject    handle to shape (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of shape as text
%        str2double(get(hObject,'String')) returns contents of shape as a double



%fid = fopen('C:\Users\Vikcy\Desktop\Files\Values.txt');
%C = textscan(fid, '%s')


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on button press in preTar.
function preTar_Callback(hObject, eventdata, handles)
% hObject    handle to preTar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;

J=int32(str2num(J));
J=J-1;
J=int2str(J);

Tfilename = strcat(I,'-',J,'.jpg');

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

for i = 1:count
    tline = fgetl(fid);
end

C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});

Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

axes(handles.axes1);
imshow(image)

% --- Executes on button press in nexTar.
function nexTar_Callback(hObject, eventdata, handles)
% hObject    handle to nexTar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;

J=int32(str2num(J));
J=J+1
J=int2str(J);

Tfilename = strcat(I,'-',J,'.jpg');

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

for i = 1:count
    tline = fgetl(fid);
end

C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});

Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar); 
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

axes(handles.axes1);
imshow(image)

2 Answers 2

1

From the Matlab documentation:

Functions end with either an end statement, the end of the file, or the definition line for a local function, whichever comes first. The end statement is required if:

  • Any function in the file contains a nested function (a function completely contained within its parent).
  • The function is a local function within a function file, and any local function in the file uses the end keyword.
  • The function is a local function within a script file.

You use the end keyword in your function Orient_CreateFcn, so all of your local functions require an end statement.


This is good coding practise anyway, as it makes your code more clear. For example it clarifies whether a local function is nested or not without having to find the parent function's end

Sign up to request clarification or add additional context in comments.

1 Comment

end keyword in Orient_CreateFcn, is used to end the if statement's block I guess
0

You have an extra end on line 45, just delete it. See below

    gui_mainfcn(gui_State, varargin{:});
end
end % <- this one

7 Comments

Thanks buddy, it sorted out that parse error. But now I'm error in line 43 saying: Error in GUI (line 43) gui_mainfcn(gui_State, varargin{:}); I'm a noobie in MatLab. @Vahe Tshitoyan
@Wolfie I know, but when you automatically generate a GUI (e.g. using guide), end is skipped for all the functions. I assume another solution would be to put the end everywhere..
Yes you need to put end everywhere (at the end of each function) because it is used within a function, see my answer! The new error is likely because of the same issue in another disguise
@StupidGuy try putting an end at the end of each function and testing it, see if it works. I do not get the same error you do on line 43, but I do not have the fig file so I cannot test it properly
@Wolfie sure, but I think end here refers to its usage to end a function, not just the end keyword in general. E.g. to end an if statement inside the function, which always requires an end.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.