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 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Rik
Rik il 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.

Categorie

Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by