I need some help with Undefined function 'plot_button_Callback' for input arguments of type 'struct'.
Show older comments
I have two logged data files each one contains a time array and an engine speed array. They are in the base work space as a b c d as 2138x1 doubles. I want to pass a b c d into a function so that the user can plot them and time align the two data sets by shifting the second time array with an offset typed into an input box. So I grabbed the two_axes example and edited it to get the following function and nested functions (I nested them so that a b c d would be available ti the sub functions). I call timealign from my main m file like this timealign(a, b, c, d); Where a is time array 1, b is rpm array 1, c is time array 2 and d is rpm array 2.
The problem is that when I push the plot button in the gui I get this error "Undefined function 'plot_button_Callback' for input arguments of type 'struct'." and I just can't understand how to fix this and make it work so I can't get any further with developing the code to do the time aligning or test it. I am not passing a b c d in as structures just as arrays so I don't understand the error.
I struggle with the "object orientated" type coding so if you give answer please provide an edited version of the code rather than a verbal explanation which i might not understand enough to implement successfully. I have attached the 3 files.
Thanks in advance for any help
function varargout = timealign(varargin)
%TIMEALIGN M-file for timealign.fig
% TIMEALIGN, by itself, creates a new TIMEALIGN or raises the existing
% singleton*.
%
% H = TIMEALIGN returns the handle to a new TIMEALIGN or the handle to
% the existing singleton*.
%
% TIMEALIGN('Property','Value',...) creates a new TIMEALIGN using the
% given property value pairs. Unrecognized properties are passed via
% varargin to timealign_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% TIMEALIGN('CALLBACK') and TIMEALIGN('CALLBACK',hObject,...) call the
% local function named CALLBACK in TIMEALIGN.M with the given input
% arguments.
%
% *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 timealign
% Last Modified by GUIDE v2.5 14-Jan-2015 09:14:03
InputArgs = (varargin);
a = varargin{1};
b = varargin{2};
c = varargin{3};
d = varargin{4};
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @timealign_OpeningFcn, ...
'gui_OutputFcn', @timealign_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 timealign is made visible.
function timealign_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 unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for timealign
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes timealign wait for user response (see UIRESUME)
% uiwait(handles.figure1);
end
% --- Outputs from this function are returned to the command line.
function varargout = timealign_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;
end
function time2offset_input_Callback(hObject, eventdata, handles)
% hObject handle to time2offset_input (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 time2offset_input as text
% str2double(get(hObject,'String')) returns contents of time2offset_input as a double
% Validate that the text in the time2offset field converts to a real number
time2offset = str2double(get(hObject,'String'));
if isnan(time2offset) || ~isreal(time2offset)
% isdouble returns NaN for non-numbers and time2offset cannot be complex
% Disable the Plot button and change its string to say why
set(handles.plot_button,'String','Cannot plot time2offset')
set(handles.plot_button,'Enable','off')
% Give the edit text box focus so user can correct the error
uicontrol(hObject)
else
% Enable the Plot button with its original name
set(handles.plot_button,'String','Plot')
set(handles.plot_button,'Enable','on')
end
end
% --- Executes on button press in plot_button.
function plot_button_Callback(hObject, eventdata, handles)
% hObject handle to plot_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get user input from GUI
time2offset = str2double(get(handles.time2offset_input,'String'));
% Calculate data
newtime = b + time2offset;
% Create time plot in axes
plot(handles.time_axes, a, c)
plot(handles.time_axes, newtime, d)
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!