Error while evaulating uicontrol Callback. Troubles using slider uicontrol

12 visualizaciones (últimos 30 días)
Sean
Sean el 11 de Dic. de 2013
Editada: Sean el 11 de Dic. de 2013
Hey all,
I have a bunch of data which I would like to plot versus time. Because this data was taken over the course of three hours I'd like to add a slider to my plots in order to better view the data. The plots are 2,1 subplots and I'd like the slider to move both plots simultaneously so data can be compared. My problem is that when I run the code, some plots work fine, and some don't. I can't find the error anywhere! I just constantly get this message when trying to move some:
??? Error while evaluating uicontrol Callback
??? Error using ==> set Bad property value found. Object Name : uicontrol Property Name : 'XLimInclude'.
OR
??? Error while evaluating uicontrol Callback
??? Error using ==> set Invalid handle object.
THINGS I'VE NOTICED: When I run the code multiple times, it's always the same plots which don't work. If I plot a different number of plots (only columns 1-10 of data on different plots instead of 1-20) some plots will still not work BUT not the same plots. I.E. By changing the bounds I can get a plot which previously didn't work to work. I'm lost! I'll add my code below: I tried to remove as much non-essential stuff as possible.
CODE:
%% miscellaneous definitions
close all
clear all
clc
format long;
dateformat='HH:MM:SS.FFF';
%% Load the correct data
[filename, pathname] =uigetfile({'*.*';'*.csv*';'*.xls*'; '*.xlsx*';'*.CO2*'}, 'Which data would you like to work with?', 'C:\Users\Sean E\Documents\APSF', 'MultiSelect', 'off'); LoadData(filename, pathname);
%%
for i=4:22
figure(i-3); %create figure
eval(strcat('h',num2str((i-3)*2-1),'=subplot(2,1,1);')); %subplot
plot(C{1,1}(1:end),C{1,i}(1:end)); %plot (time array) vs (data array)
title(headernames(1,i)); % graph formatting
xlabel('Time'); % graph formatting
ylim([min(C{1,i})-.05*min(C{1,i}), max(C{1,i})+.05*max(C{1,i})]);
set(gca,'XTick',newtimesmat); % graph formatting
set(gca,'XTickLabel',times); % graph formatting
eval(strcat('h',num2str((i-tstart+1)*2),'=subplot(2,1,2);')) %create subplot
plot(C{1,1}(1:end),C{1,18}(1:end)); %plot (time array) vs (reference data)
title(headernames(1,18)); % graph formatting
xlabel('Time'); % graph formatting
ylim([min(C{1,18})-.05*min(C{1,18}), max(C{1,18})+.05*max(C{1,18})]);
set(gca,'XTick',newtimesmat); % graph formatting
set(gca,'XTickLabel',times); % graph formatting
dx=0.002083333325572; %defining constants
x=newtimesmat; %defining constants
eval(strcat('varargin={h' ,num2str((i-tstart+1)*2-1),',h',num2str((i-...
...tstart+1)*2),'};'));
a=gca; %defining constants
set(a,'xlim',[0 dx]); %defining constants
pos=get(a,'position'); %defining constants
xmax=max(x); %defining constants
xmin=min(x); %defining constants
Newpos=[pos(1) pos(2)-0.1 pos(3) 0.05]; %defining constants
for k = 1:length(varargin);
%initialize postion of plot
set(varargin{k},'xlim',[xmin xmin+dx]);
% Creation of variables b1...bn
eval(['b',num2str(k+(i-tstart+1)+(i-tstart-1)), ' = varargin{k};'])
% Setting up callback string to modify XLim of axis (gca)
% based on the position of the slider (gcbo)
if k == 1;
S=['set(b', num2str(k+(i-tstart+1)+(i-tstart-1)), '...
...,''xlim'',get(gcbo,''value'')+[0 ' num2str(dx) ']);'];
else
S=[S ', set(b', num2str(k+(i-tstart+1)+(i-tstart-1)), ' ...
...,''xlim'',get(gcbo,''value'')+[0 ' num2str(dx) ']);'];
end
end
% Creating Uicontrol with initial value of the minimum of x
eval(strcat('b',num2str(i),'=uicontrol(''style'',''slider'',''units'',''normalized'',...
...''position'',Newpos,''callback'',S,''min'',xmin,''max'',xmax-dx,''value'',xmin);'));
end

Respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by