Why is my script not publishing the figure?

152 次查看(过去 30 天)
Greetings guys!
I don't understand why, when I publish this script, the figure (plot and histogram) isn't being published along with the code.
The code is the following:
%% BETA DISTRIBUTION HOMEWORK
clear;
clc;
% "Subordinated" Bonds:
mu = 0.35;
sigma = 0.25;
%% Ex. 1
X = 0:0.00001:1;
Y = betapdf(X,a(mu,sigma),b(mu,sigma));
%% Ex. 2
R = betarnd(a(mu,sigma),b(mu,sigma),1,10000);
figure
subplot(2,1,1)
plot(X,Y)
title('Beta densities consistent with empirical \mu = 35% and \sigma = 25%','fontsize',12)
xlabel('Recovery rate','fontsize',10)
subplot(2,1,2)
hist (R)
title('Histogram','fontsize',14)
xlabel('Recovery rate','fontsize',10)
%% Functions
function a_par = a(mu,sigma)
a_par = mu*(mu*(1-mu)/sigma^2 - 1);
end
function b_par = b(mu,sigma)
b_par = (1-mu)*(mu*(1-mu)/sigma^2 - 1);
end

回答(1 个)

Nagini Venkata Krishna Kumari Palem
I understand that you wish to display figures in your published document. MATLAB has 'snapnow' command which forces the snapshot to be included in published document. All you need to do is add the 'snapnow' command after plotting figure. For example, in your case,
hist (R)
title('Histogram','fontsize',14)
xlabel('Recovery rate','fontsize',10)
snapnow
For more information you can take a look at the following documentation snapnow

Community Treasure Hunt

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

Start Hunting!

Translated by