Plotting a Sequence over a Given Interval

์กฐํšŒ ์ˆ˜: 4 (์ตœ๊ทผ 30์ผ)
Connor Wright
Connor Wright 2021๋…„ 1์›” 9์ผ
๋‹ต๋ณ€: Star Strider 2021๋…„ 1์›” 9์ผ
I am trying to plot the follwing sequence,
๐‘ฅ(๐‘›) = ๐‘›[๐‘ข(๐‘›) โˆ’ ๐‘ข(๐‘› โˆ’ 10)]+ 10๐‘’ โˆ’0.(๐‘›โˆ’10) [๐‘ข(๐‘› โˆ’10) โˆ’ ๐‘ข(๐‘› โˆ’ 20)]
Over this interval
0 โ‰ค ๐‘› โ‰ค 20
I already have some code from a previous attempt at this type of problem which is as follows,
% USMPL Function %
function delta = usmpl(n)
if n == 1
delta = 1
else
delta = 0
end
% Main Code %
n = -10:10
x = zeros(length(n)
for k = 1:length(n)
x(k) = 2*usmpl(n(k)+ 1) - usmpl(n(k)-6);
end
stem(n,x)
The problem I am having is working out what to put where in this code to make it work for this problem.
Thanks.
  ๋Œ“๊ธ€ ์ˆ˜: 4
Star Strider
Star Strider 2021๋…„ 1์›” 9์ผ
Regardless of what โ€˜nโ€™ is, that simply evaluates as 10, since always evaluates as 1.
Example โ€”
n = 42;
expr = 10*exp(-0*(n-10))
.
Connor Wright
Connor Wright 2021๋…„ 1์›” 9์ผ
So would it be feesible to just modify my USMPL code and make u the focus instead of delta?

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Star Strider
Star Strider 2021๋…„ 1์›” 9์ผ
I have no idea.
I would just do something like this, and hope for the best with respect to whatever that exp() call is supposed to do:
u = @(t) t>=1;
x = @(n) n.*(u(n)-u(n-10) + 10*exp(-0*(n-10)) .* (u(n-10)-u(n-20)));
n = linspace(0, 20, 1000);
figure
plot(n, x(n))
grid
Make appropriate changes when you resolve the problem with the exponential term.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Logical์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by