How do I multiply Sin and stepseq functions?

2 ビュー (過去 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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by