Connect uitable to specific figure
2 次查看(过去 30 天)
显示 更早的评论
So I've added a uitable to a figure in order to be able to distinguish the min and max value for a certain time span. By looking at the plot the user can approximately tell at what time the min & max should occur, in order to be find actual min & max one has to study the table since it is hard to distinguish these from looking only at the plot. The use then enters at what time the min & max occur in a input dialogue. There is probably a much more efficient way to do this but this works fine.
The problem is however the uitable. I thought it would be connected only to the figure mentioned above, however when i plotted other results obtained later in the code the uitable showed up in this figure as well.
Here is the code:
figure('position',[0,0,1440,990])
plot(xtim,v_timav,'black',xtim,h_timav,'r');
set(gca,'Xtick',xtim,'XTickLabelRotation',45,'Xgrid','on','ylim',[0 65]);
datetick('x','HH:MM');
title('Normalday','Fontsize',16,'Fontweight','normal')
xlabel('[ h ]','Fontsize',14,'Color',[0.5 0.5 0.5]);
ylabel('[ l/s ]','Fontsize',14,'Color',[0.5 0.5 0.5]);
le2=legend('Veckodag','Helgdag','Location','northeast');
set(le2,'Fontsize',12);
cnames = {'Veckodag','Helgdag'};
rnames = {'00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00'...
'16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00'};
uitable('Position',[205,370,230,360],'Data',averageday,'ColumnName',cnames,'RowName',rnames)
How do I make it stay out of my other figures?
0 个评论
采纳的回答
Walter Roberson
2016-1-20
fig = figure('position',[0,0,1440,990]);
ax = axes('Parent', fig);
ph = plot(ax, xtim,v_timav,'black',xtim,h_timav,'r');
set(ax'Xtick',xtim,'XTickLabelRotation',45,'Xgrid','on','ylim',[0 65]);
datetick(ax, 'x','HH:MM');
title(ax, 'Normalday','Fontsize',16,'Fontweight','normal')
xlabel(ax, '[ h ]','Fontsize',14,'Color',[0.5 0.5 0.5]);
ylabel(ax, '[ l/s ]','Fontsize',14,'Color',[0.5 0.5 0.5]);
le2 = legend(ax, ph, 'Veckodag','Helgdag','Location','northeast');
set(le2,'Fontsize',12);
cnames = {'Veckodag','Helgdag'};
rnames = {'00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00'...
'16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00'};
uitable('Parent', fig, 'Position',[205,370,230,360],'Data',averageday,'ColumnName',cnames,'RowName',rnames)
Now all the graphics are certain to go to the right place.
2 个评论
Walter Roberson
2016-1-20
With the code you had, if you accidentally click a different figure while this code is running, then the uitable would get attached to the other figure. That includes if you drop into the debugger and move a window to be able to see what you are doing, and also includes if a callback happened that updated a different figure or if you called a function that updated a different figure. With the code I give here, you can click or debug or call functions all you like and the graphics would still go to the right place.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!