a tiledlayout issue via a subfunction
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Emirhan Solmaz
le 12 Avr 2022
Commenté : Emirhan Solmaz
le 13 Avr 2022
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 commentaires
Réponse acceptée
Matt J
le 12 Avr 2022
Modifié(e) : Matt J
le 12 Avr 2022
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
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!