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 view (last 30 days)
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

Answers (1)

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

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!