Hot answers tagged

1

Check the interval of x and then covert logical to double. f1 = @(x) double(pi-1 <= x && x <= pi+1); Or if the initial condition is not 1 and 0, write a function function u = f1(x) u = zeros(size(x)); is_one = pi-1 <= x && x <= pi+1; u(is_one) = 1; % u(~is_one) = 0; not required, just for your reference end Edit:...


Only top voted, non community-wiki answers of a minimum length are eligible