Why is my script not publishing the figure?

152 Ansichten (letzte 30 Tage)
David Lopes
David Lopes am 28 Mär. 2017
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

Antworten (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
  2 Kommentare
Samuel Abimbola Ogunfuye
Samuel Abimbola Ogunfuye am 20 Jun. 2019
Great .. it works perfectly.. Appreciate it.. Thanks a lot

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by