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 ?

2 vues (au cours des 30 derniers jours)
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

Réponses (1)

Rik
Rik le 25 Nov 2020
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.

Catégories

En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by