How do I multiply Sin and stepseq functions?

조회 수: 20 (최근 30일)
Hey kim
Hey kim 2021년 5월 2일
답변: Star Strider 2021년 5월 2일
x(t) = sin(2Πt)[u(t+1)-u(t-1)]
How do I multiply Sin and stepseq functions?
t=-1:1;
a = sin(2*pi*t);
b = stepseq(-1, -1, 1)-stepseq(1, -1, 1);
h = a.*b;
subplot(2,1,2);
title('5-19_d');xlabel('t');ylabel('x[t]');
It was originally intended to do this, but the size of the arrangement was not compatible. How can I multiply it?

답변 (1개)

Star Strider
Star Strider 2021년 5월 2일
I have no idea what you are doing, and I had to look up ‘stepseq’, since I have never heard of it before.
Experiment with this to get the result you want —
t=-10:10;
a = sin(2*pi*t/11);
[x1,n1] = stepseq(-1, -10, 10);
[x2,n2] = stepseq(1, -1, 19);
b = x1-x2;
h = a.*b;
subplot(2,1,2);
plot(t, h)
title('5-19_d');xlabel('t');ylabel('x[t]');
function [x,n] = stepseq(n0,n1,n2) % Copied From: <https://www.mathworks.com/matlabcentral/answers/12834-unsolved-function?s_tid=srchtitle#>
% Generates x(n) = u(n-n0); n1 <= n,n0 <= n2
% ------------------------------------------
% [x,n] = stepseq(n0,n1,n2)
%
if ((n0 < n1) | (n0 > n2) | (n1 > n2))
error('arguments must satisfy n1 <= n0 <= n2')
end
n = [n1:n2];
%x = [zeros(1,(n0-n1)), ones(1,(n2-n0+1))];
x = [(n-n0) >= 0];
end
I made several changes to get the code to produce something meaningful.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by