Why am I getting a 'parse error' at t and how do I fix it?
Show older comments
I am trying to write a program that returns the gaussian distribution given input arguments of a vector times t and a value of RMS deviation tau.
This is my code, but it keeps saying there is a parse error at line 14: "Parse error at t: usage might be invalid MATLAB syntax"
% Write a program that returns the Gaussian distribution given input
% arguments of a vector of times t and a value of a root mean squared (RMS)
% deviation tau
function gaussian_distribution = generate_gaussian(t, tau)
% t: Vector of times
% tau: RMS deviation
% Calculate the Gaussian distribution
gaussian_distribution = exp(-t.^2 / (2 * tau^2)) / (tau * sqrt(2 * pi));
end
% Example usage and plot
t = linspace(-5, 5, 1000); % Example time vector
tau = 1.5; % Example RMS deviation
% Generate Gaussian distribution
gaussian_dist = generate_gaussian(t, tau);
% Plot the Gaussian distribution
figure;
plot(t, gaussian_dist, 'LineWidth', 2);
title('Gaussian Distribution');
xlabel('Time');
ylabel('Amplitude');
grid on;
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!