I am trying to create a standalone executable to be run on a windows system that will compare 2 txt files. I have been trying to do this from MATLAB. I love the way that the visdiff
tool works in MATLAB, but when I compile the file using the Application compiler in MATLAB and run the program the visdiff
tool does not appear. Using the visdiff
tool is not necessary, but it is a nice pre-built tool.
Here is the code that I tried to use. It was created using the MATLAB 'GUIDE' tool. I then tried to compile it in MATLAB R2015b clicking the 'APPS' in the ribbon then "APPLICATION COMPILER".
function varargout = Comparator(varargin)
% COMPARATOR MATLAB code for Comparator.fig
% COMPARATOR, by itself, creates a new COMPARATOR or raises the existing
% singleton*.
%
% H = COMPARATOR returns the handle to a new COMPARATOR or the handle to
% the existing singleton*.
%
% COMPARATOR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in COMPARATOR.M with the given input arguments.
%
% COMPARATOR('Property','Value',...) creates a new COMPARATOR or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Comparator_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Comparator_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 Comparator
% Last Modified by GUIDE v2.5 11-Dec-2015 13:20:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Comparator_OpeningFcn, ...
'gui_OutputFcn', @Comparator_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 initialization code - DO NOT EDIT
% --- Executes just before Comparator is made visible.
function Comparator_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 Comparator (see VARARGIN)
% Choose default command line output for Comparator
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Comparator wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Comparator_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 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)
[FName, PathName, FilterIndex] = uigetfile('*.txt')
% set(hOject,'String',FName)%%%%%%%%%%CHANGE THIS!!!!!!!!!
handles.fid1=FName;
guidata(hObject,handles)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FName, PathName, FilterIndex] = uigetfile('*.txt')
% set(hOject,'String',FName)%%%%%%%%%%CHANGE THIS!!!!!!!!!
handles.fid2=FName;
guidata(hObject,handles)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
visdiff(handles.fid1,handles.fid2)
I am also playing around creating one from scratch as follows:
clc;clear;
fid1 = fopen('t1.txt', 'r');
fid2 = fopen('t2.txt', 'r');
lines1 = textscan(fid1,'%s','delimiter','\n');
lines2 = textscan(fid2,'%s','delimiter','\n');
lines1 = lines1{1};
lines2 = lines2{1};
fclose(fid1);
fclose(fid2);
[idx1 idx2] = ismember(lines1,lines2);
Any advise about how to make the visdiff
tool work in a standalone or create a new tool would be appreciated.