This fails, I believe, for asymmetric peaks. Try y = [0:4 , 3:-1:1,1,1,1,1,1]
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%% 1
y = [0 1 2 3 4 3 2 1 0];
F = 4;
assert(abs((fwhm(y)-F)/F)<0.1)
|
2 | Pass |
%% 2
y = [0, 1:10, 9:-1:1, 0];
F = 10;
assert(abs((fwhm(y)-F)/F)<0.1)
|
3 | Pass |
%% 3
y = [0 1 1 1 1 0]';
F = 4;
assert(abs((fwhm(y)-F)/F)<0.1)
|
4 | Pass |
%% 4
y = [zeros(1,3),ones(1,10),zeros(1,5)];
F = 10;
assert(abs((fwhm(y)-F)/F)<0.1)
|
5 | Pass |
%% 5
for i = 1:200
maxX = randi(10) + 10;
F = rand*4+1;
x = -maxX:maxX;
y = exp(-4*log(2)*x.^2/F^2);
assert(abs((fwhm(y)-F)/F)<0.1)
end
|
6 | Pass |
%%
user_solution = fileread('fwhm.m');
assert(isempty(strfind(user_solution,'regexp')));
assert(isempty(strfind(user_solution,'num2str')));
assert(isempty(strfind(user_solution,'fprintf')));
assert(isempty(strfind(user_solution,'assert')));
|
3113 Solvers
232 Solvers
Calculate the Hamming distance between two strings
178 Solvers
Is this triangle right-angled?
2874 Solvers
Is this triangle right-angled?
2394 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!