I'm trying to input a data set to calculate the Gaussian (Normal) Distribution. This something that i found on youtube but I keep getting the error: Error in my_gaussian (line 4) f = zeros(n, 1); When i hit Run. What is this error about ?

1 回表示 (過去 30 日間)
James Epkins Jr.
James Epkins Jr. 2020 年 11 月 25 日
回答済み: Rik 2020 年 11 月 25 日
function [ X, f ] = my_gaussian( mu, sigma_sq, min_x, max_x, n)
f = zeros(n, 1);
X = zeros(n, 1);
x = min_x;
dx = (min_x - max_x)/n;
for i = 1:n
X(i) = x;
f(i) = 1/ sqrt(2*pi*sigma_sq) * exp( -(x - mu)^2 / (2 * sigma_sq) );
x = x + dx
end

回答 (1 件)

Rik
Rik 2020 年 11 月 25 日
How is Matlab supposed to know the input values? If you hit the green run button you execute the function without any inputs.
You need to run this function with inputs.

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by