Heaviside function in Matlab.
10 次查看(过去 30 天)
显示 更早的评论
I have two sets of values, A and B. and I would to write a Heaviside function such that it returns 0, when A is less than B, and returns 1, when A is greater than B.
0 个评论
采纳的回答
Star Strider
2018-2-19
I am not certain what result you want.
Try this:
A = randi([2 3], 1, 30); % Create ‘A’
B = randi([2 3], 1, 30); % Create ‘B’
T = 1:numel(A); % Create Time Reference
HF = @(a,b) (a > b); % Function
figure(1)
plot(T, A, T, B)
hold on
plot(T, HF(A,B), 'LineWidth',2)
hold off
ylim = [-0.1 3.1];
legend('A', 'B', 'HF(A,B)', 'Location','E')
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!