a tiledlayout issue via a subfunction
조회 수: 1 (최근 30일)
이전 댓글 표시
When I run the main code (all the below are sample codes), the tiledlayout figure appears but figures were been drawned seperately. When I remove all the sets and other stuff from the PlotSubFunction, the codes works properly. Could you help me to solve the issue please? I have to keep the sets and the other stuff. So, the solution might be somehow a different approach to keep them. I don't know really.
The main code :
m=3;
n=2;
PlotTiled(m,n)
The PlotTiled function :
function PlotTiled(m,n)
tempTiledFig = tiledlayout(m,n,'TileSpacing','compact','Padding','compact');
for tempPlotTileRow = 1:m
for tempPlotTileCol = 1:n
randCol = m+n+1;
nexttile(tempTiledFig)
PlotSubFunction(randCol);
end
end
end
The PlotSubFunction function:
function PlotSubFunction(randCol)
randNums = rand(1,randCol);
figSubPlots = figure('Name','A11', 'NumberTitle','off',...
'PaperOrientation','landscape','PaperType','A2',...
'WindowState','maximized','Renderer','painters');
axes1 = axes('Parent',figSubPlots,'Position',[0.13 0.11 0.775 0.815]);
hold(axes1,'on');
plot(randNums);
box(axes1,'on');
hold(axes1,'off');
set(axes1,'TickDir','out','XGrid','on','YGrid','on');
xlim([0 length(randNums)]);
end
댓글 수: 0
채택된 답변
Matt J
2022년 4월 12일
편집: Matt J
2022년 4월 12일
PlotTiled(3,2)
function PlotTiled(m,n)
tempTiledFig = tiledlayout(m,n,'TileSpacing','compact','Padding','compact');
figSubPlots = figure('Name','A11', 'NumberTitle','off',...
'PaperOrientation','landscape','PaperType','A2',...
'WindowState','maximized','Renderer','painters');
for tempPlotTileRow = 1:m
for tempPlotTileCol = 1:n
randCol = m+n+1;
ax=nexttile(tempTiledFig);
PlotSubFunction(randCol,ax);
end
end
end
function PlotSubFunction(randCol,axes1)
randNums = rand(1,randCol);
% hold(axes1,'on');
plot(randNums);
box(axes1,'on');
% hold(axes1,'off');
set(axes1,'TickDir','out','XGrid','on','YGrid','on');
xlim([0 length(randNums)]);
end
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!