So, I answered my own question. I created a test program and used link data and refresh data to successfully update a control chart based on the users column selection. Using GUIDE i created a quick gui with a single uitbale and plot axes. the code below is the opening function and a custom refresh function I created which is called every time the user selects or edits a cell. Below is the test program I used:
% --- Executes just before LinkDataTest is made visible.
function LinkDataTest_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 LinkDataTest (see VARARGIN)
% Choose default command line output for LinkDataTest
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
X=[1:4]
UiTableData=get(handles.uitable1,'Data')
UiTableDataCol=UiTableData(:,1)
UiTableDataColDBL=cellfun(@str2double,UiTableDataCol)';
assignin('base','UiTableDataColDBL',UiTableDataColDBL)
Y=UiTableDataColDBL
%p=plot(X,Y,'*','Parent',handles.axes1)
width=X(end)
sigma=std(UiTableDataColDBL)
if isnan(sigma)==1 || strcmpi('NaN',sigma)==1
sigma=1
end
ControlLimits=[7.55 7.60 7.65]
p=controlchart(Y,'chart','i','width',width,'sigma',sigma,'limits',ControlLimits,'Parent',handles.axes1)
% line([0 4],[4 4],'Color','b')
% line([0 4],[3 3],'Color','r')
% line([0 4],[1 1],'Color','b')
p.XDataSource='X';
p.YDataSource='Y';
p.sigma='sigma';
p.width='width';
p.limits='ControlLimits'
linkdata on
function refreshchart(handles)
uiIndex=findjobj(handles.uitable1);
cols=uiIndex.getComponent(0).getComponent(0).getSelectedColumns+1;
UiTableData=get(handles.uitable1,'Data')
UiTableDataCol=UiTableData(:,cols)
UiTableDataColDBL=cellfun(@str2double,UiTableDataCol)';
assignin('base','UiTableDataColDBL',UiTableDataColDBL)
X=[1:4]
Y=UiTableDataColDBL
width=X(end)
sigma=std(UiTableDataColDBL)
if isnan(sigma)==1 || strcmpi('NaN',sigma)==1
sigma=1
end
refreshdata(handles.axes1,'caller')
