Error message on titled layout code
4 views (last 30 days)
Show older comments
I would like to print all graphs together. For that I use the following code.
titledlayout(6,1)
% First plot - exponential vs. normal distribution
ax1 = nexttile;
qqplot(ax1, expo_r, normal_r)
title (ax1, 'Q- Q Plot for Exponential Dist. vs Normal Dist.')
xlabel (ax1, 'Exponential Dist.')
ylabel (ax1, 'Normal Dist.')
% Second plot - exponential vs. lognormal distribution
ax2 = nexttile;
qqplot(ax2, expo_r, lognormal_r)
title (ax2, 'Q- Q Plot for Exponential Dist. vs Logormal Dist.')
xlabel (ax2, 'Exponential Dist.')
ylabel (ax2, 'Logormal Dist.')
% Third plot - exponential vs. Gamma distribution
ax3 = nexttile;
qqplot(ax3, expo_r, gamma_r)
title (ax3, 'Q- Q Plot for Exponential Dist. vs Gamma Dist.')
xlabel (ax3, 'Exponential Dist.')
ylabel (ax3, 'Gamma Dist.')
% Fourth plot - Normal vs. Lognormal distribution
ax4 = nexttile;
qqplot(ax4, normal_r, lognormal_r)
title (ax4, 'Q- Q Plot for Normal Dist. vs Lognormal Dist.')
xlabel (ax4, 'Normal Dist.')
ylabel (ax4, 'Lognormal Dist.')
% Fifth plot - Normal vs. Gamma distribution
ax5 = nexttile;
qqplot(ax5, normal_r, gamma_r)
title (ax5, 'Q- Q Plot for Normal Dist. vs Gamma Dist.')
xlabel (ax5, 'Normal Dist.')
ylabel (ax5, 'Gamma Dist.')
% Sixth plot - Lognormal vs. Gamma distribution
ax6 = nexttile;
qqplot(ax6, lognormal_r, gamma_r)
title (ax6, 'Q- Q Plot for Lognormal Dist. vs Gamma Dist.')
xlabel (ax6, 'Logormal Dist.')
ylabel (ax6, 'Gamma Dist.')
However, I get the following error message and I cannot see graphs
Undefined function or variable 'titledlayout'.
Error in example_work_file (line 75)
titledlayout(6,1)
How can I correct my code? Please help me. Thanks a lot.
0 Comments
Accepted Answer
Rik
on 11 May 2020
Edited: Rik
on 12 May 2020
For releases before R2019b you can use subplot. You could use a wrapper like the one below.
function tiledlayout(m,n)
tiledlayout_data=struct;
tiledlayout_data.m=m;
tiledlayout_data.n=n;
tiledlayout_data.p=0;
setappdata(gcf,'tiledlayout',tiledlayout_data)
end
function ax=nextplot
try
tiledlayout_data=getappdata(gcf,'tiledlayout');
catch
error('call tiledlayout first')
end
tiledlayout_data.p=tiledlayout_data.p+1;
setappdata(gcf,'tiledlayout',tiledlayout_data);
ax=subplot(m,n,p);
end
3 Comments
Rik
on 12 May 2020
This function was introduced in R2019b. Which release are you using? For older releases you should consider subplot for a similar functionality.
More Answers (0)
See Also
Categories
Find more on 3-D Scene Control in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!