您的问题很笼统,因此根据细节可能会有更多解决方案。但是,一种非常通用的方法是以下一种:
假设您有一个函数plotSingleChannel 将通道数据和GUI 上可用的位置作为输入,您可以在for 循环中调用它的次数与通道数一样多。一个玩具示例是,您需要根据自己的需要对其进行调整(例如,可能打开一个以上的图形来处理多个频道):
function plotManyChannels
fgui = figure;
numChannels = 5;
chData = rand (numChannels , 1000); % 5 random channels
chHeight = .8 * 1/numChannels; % occupy 80% of the available space, in order to leave some free inter-channel margins
for n = 1 : numChannels
pos = [.05, 1 - n / numChannels, .9, chHeight];
plotSingleChannel (chData(n,:), fgui, pos);
end
end
function plotSingleChannel (channelData, figHandle, guiPosition)
figure(figHandle)
buttonWidth = .1;
buttonPosition = [1-buttonWidth,guiPosition(2),buttonWidth,guiPosition(4)];
axHandle = axes ('position', guiPosition - [0 0 buttonWidth 0]);
plot(axHandle, channelData);
btnHandle = uicontrol('parent',figHandle,'style','pushbutton','string','push','units','normalized','position',buttonPosition);
end