フィルターのクリア

Why is my script not publishing the figure?

21 ビュー (過去 30 日間)
David Lopes
David Lopes 2017 年 3 月 28 日
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
Nagini Venkata Krishna Kumari Palem 2017 年 3 月 30 日
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 件のコメント
Samuel Abimbola Ogunfuye
Samuel Abimbola Ogunfuye 2019 年 6 月 20 日
Great .. it works perfectly.. Appreciate it.. Thanks a lot
Samuel Abimbola Ogunfuye
Samuel Abimbola Ogunfuye 2019 年 6 月 20 日

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by