0

我正在为我们的工程团队创建一个工具,以查看来自我们现场系统的数据。基础数据对它并不重要。基本上,它由包含 X 时间的 Y 数据的向量组成。

我正在使用 subplot 绘制一系列向量。每个绘图都定义了 ButtonDownFcn 以启动一个允许进行更深入分析的窗口。问题是,当我单击已部署应用程序中的轴时,什么也没有发生。没有错误消息或任何东西。当我单击在 Matlab 中运行它的轴时,它完全按预期工作。

我不确定一旦部署了阻止其正常运行的代码会发生什么。我有点不知道该去哪里。我已经包含了我的代码和一些示例数据。

测试数据:

stats = struct('name','Car 54', ...
    'date', '11-Aug-2014');
stats.SOC = struct('time', linspace(1,24,100)*3600', ...
    'plugdata', [100*ones(20,1); NaN(70,1); (20:4:56)'], ...
    'drivedata', [NaN(20,1); (100:-2:60)'; NaN(10,1); (40:-2:20)'; NaN(20,1); (30:-2:16)'; NaN(10,1)], ...
    'eptodata', [NaN(41,1); (58:-2:40)'; NaN(11,1); (18:-2:5)'; NaN(13,1); NaN(7,1); NaN(11,1)], ...
    'engchargedata', [NaN(69,1); (5:2:30)'; NaN(18,1)], ...
    'otherdata', NaN(100,1));

代码:

function [output] = summarytablepopup(stats)

FH = figure('Name','Summary Table Popup', ...
    'Units', 'normalized', ...
    'Position', [0.05 0.05 0.9 0.8], ...
    'Tag', 'sumTablePU', ...
    'Toolbar', 'none', ...
    'NumberTitle', 'off', ...
    'WindowStyle', 'normal', ...
    'Resize', 'on', ...
    'CloseRequestFcn', @closereq, ...
    'MenuBar', 'none', ...
    'UserData', {});
movegui(FH,'onscreen')

noStats = numel(stats);
screensize = get(0,'ScreenSize');
mapIMG = imread([pwd '\icons\map.jpg']);

noGraphs = 5;
AH = NaN(noStats,1); % axes handles
TT = NaN(noStats,1); % name text handles
MB = NaN(noStats,1); % map button handles
TH = NaN(ceil(noStats/noGraphs),1); % tab handles

warning('off','all')
TGH = uitabgroup('Parent',FH); % tab group handle
for ii = 1:length(TH)
    TH(ii) = uitab('parent',TGH,'title',sprintf('Page %d',ii));
end
warning('on','all')

for ii = 1:noStats
    currentPage = ceil(ii/noGraphs);
    vehiclename = stats(ii).name;
    vehicledate = stats(ii).date;

    if isfield(stats(ii),'SOC') && ~isempty(stats(ii).SOC) && isfield(stats(ii).SOC,'time') && ~isempty(stats(ii).SOC.time)
        SOC = stats(ii).SOC;
        time = SOC.time/3600;
        subplot(5,1,mod(ii-1,noGraphs)+1,'Parent',TH(currentPage))
        HH = plot(time, SOC.plugdata, 'g-x', ...
            time, SOC.eptodata, 'b-x', ...
            time, SOC.engchargedata, 'b-x', ...
            time, SOC.drivedata, 'r-x', ...
            time, SOC.otherdata, 'k-x');
        AH(ii) = get(HH(1),'Parent');
        set(HH,'Marker','.')
        set(HH(3),'Color',[0 0.75 1])
        set(HH(3),'MarkerFaceColor',[0 0.75 1])
    else
        subplot(5,1,mod(ii-1,noGraphs)+1,'Parent',TH(currentPage))
        HH = plot([0 12 24],[NaN NaN NaN]);
        AH(ii) = get(HH(1),'Parent');
        %}
    end
    pos = get(AH(ii),'Position');
    pos(1) = 0.25;
    pos(3) = 0.72;
    set(AH(ii),'Position',pos)
    set(AH(ii),'UserData', ii)
    set(AH(ii),'ButtonDownFcn', @divedeep)
    set(AH(ii),'YLim',[0 100])
    set(AH(ii),'YTick',[0 25 50 75 100])
    set(AH(ii),'YTickLabel',{'0','25','50','75','100'})
    set(AH(ii),'XLim',[0 24])
    set(AH(ii),'XTick',[0 4 8 12 16 20 24])
    set(AH(ii),'XTickLabel',{'0000','0400','0800','1200','1600','2000','2400'})

    mapHeight = 0.1;
    mappos = [0.18 pos(2)+pos(4)/2-mapHeight/2 mapHeight*screensize(4)/screensize(3) mapHeight];
    MB(ii) = uicontrol('Parent', TH(currentPage), 'Style', 'pushbutton', ...
        'Tag', sprintf('mapButton%d',ii), ...
        'String', '', ...
        'Units', 'normalized', ...
        'Position', mappos, ...
        'CData', mapIMG, ...
        'Callback', @mapbutton);
    if isfield(stats(ii),'location') && ~isempty(stats(ii).location) && isfield(stats(ii).location,'time') && ~isempty(stats(ii).location.time)
        set(MB(ii),'Enable','on')
    else
        set(MB(ii),'Enable','off')
    end
    textHeight = 0.05;
    textpos = [0.01 pos(2)+pos(4)/2-textHeight/2 0.15 textHeight];
    TT(ii) = uicontrol('Parent', TH(currentPage), 'Style', 'text', ...
        'Tag', sprintf('text%d',ii), ...
        'String', vehiclename, ...
        'FontSize', 12, ...
        'Units', 'normalized', ...
        'Position', textpos);
end

uiwait(FH)

    function mapbutton(source, event)
        tag = get(source,'Tag');
        splittag = strsplit(tag,'n');
        jj = str2num(splittag{2});
        loc = stats(jj).location;
        if ~isempty(loc)
            len = numel(loc.time);
            map = [linspace(1,0,len)', linspace(0,1,len)', zeros(len,1)];
            MFH = figure;
            MPH = plot(loc.lon, loc.lat, 'r:');
            hold on;
            MSH = scatter(loc.lon, loc.lat, 50, 'o', 'filled', 'CData', map);
            plot_google_map
        else
            msgbox('No location information available for this vehicle. Really should disable this button.')
        end
    end

    function electric(source, event)
        ratio = get(SH,'Value')/100*(0.9-startheight)+0.05;
        set(PH, 'Position', [panpos(1) ratio panpos(3) panpos(4)])
    end

    function divedeep(source, event)
        HEDtimeplot([],stats(get(source,'UserData')));
    end

    function closereq(source,event)

        uiresume(source)
        delete(source)
    end
end
4

0 回答 0