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 visualizaciones (últimos 30 días)
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

Respuestas (1)

Rik
Rik el 25 de Nov. de 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.

Categorías

Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by