フィルターのクリア

a tiledlayout issue via a subfunction

1 回表示 (過去 30 日間)
Emirhan Solmaz
Emirhan Solmaz 2022 年 4 月 12 日
コメント済み: Emirhan Solmaz 2022 年 4 月 13 日
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

採用された回答

Matt J
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 件のコメント
Emirhan Solmaz
Emirhan Solmaz 2022 年 4 月 13 日
thank you. I would never think to use axes1 as an input.

サインインしてコメントする。

その他の回答 (1 件)

Emirhan Solmaz
Emirhan Solmaz 2022 年 4 月 12 日
for now, I just remove the "figSubPlots" and "axis1" lines. I couldn't find a solution.

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by