# Graphing a Histogram for Simulation

8 ビュー (過去 30 日間)
Leo 2023 年 3 月 28 日
コメント済み: Leo 2023 年 3 月 29 日
I am trying to do a simulation and I am having an issue with the graph, I am trying to get a histogram graph with the most frequent occurrence happening in the middle with the other value frequences on the sides but my code is only graphing what seems to be the middle bar. I have included my code as well as an image of the type of graph I am trying to recreate.
close all
delta_cp = @(t) (-2.4433*t + 7.623) + 7.3125;
n_sims = 100000;
t_range = linspace(0, 3.1, 1000);
results = zeros(1, n_sims);
for i = 1:n_sims
t = i * t_range(end);
results(i) = delta_cp(t);
end
figure
hist(results(:,1), 50);
xlabel('Change in Center of Gravity (m)')
ylabel('Frequency')
title('Simulation Results')
##### 3 件のコメント表示 2 件の古いコメント非表示 2 件の古いコメント
Leo 2023 年 3 月 29 日
Calm down John its not that deep

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

### 回答 (1 件)

Image Analyst 2023 年 3 月 28 日

How is it a distribution? You're not doing a Monte Carlo - you're not getting random numbers. Not sure what that function is. Is it a PDF or CDF or something else?
I'm attaching some Monte Carlo-related demos.
##### 1 件のコメント表示 なし非表示 なし
Leo 2023 年 3 月 29 日
Thank you, this was more helpful than just telling me that I was not doing a random number mote carlo.

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

### カテゴリ

Find more on Exponential Distribution in Help Center and File Exchange

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by