Error message on titled layout code

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.

 Respuesta aceptada

Rik
Rik el 11 de Mayo de 2020
Editada: Rik el 12 de Mayo de 2020
You have a typo: you had an extra t in tiledlayout.
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 comentarios

Okay, I tried it, again, I get the same error :(
Undefined function or variable 'tiledlayout'.
Error in project_part_1 (line 77)
tiledlayout (6,1)
Rik
Rik el 12 de Mayo de 2020
This function was introduced in R2019b. Which release are you using? For older releases you should consider subplot for a similar functionality.
Zeynep Toprak
Zeynep Toprak el 12 de Mayo de 2020
yes, I use 2017 version. subplot works! thanks a lot!! :)

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 11 de Mayo de 2020

Editada:

Rik
el 12 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by