MATLAB Answers

Plotting sequences over intervals

์กฐํšŒ ์ˆ˜: 53(์ตœ๊ทผ 30์ผ)
Connor Wright
Connor Wright 2020๋…„ 11์›” 13์ผ
ํŽธ์ง‘: Noor Hossen 2021๋…„ 7์›” 18์ผ
Hello,
How would I go about plotting a seqeunce over the below intervals?
A) ๐‘ฅ(๐‘›) = 2๐›ฟ(๐‘› + 1)โˆ’ ๐›ฟ(๐‘› โˆ’6), โˆ’10 โ‰ค ๐‘› โ‰ค 10.
B) ๐‘ฅ(๐‘›) = {โ€ฆ , 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, โ€ฆ }; โˆ’20 โ‰ค ๐‘› โ‰ค 12.
Thanks
  ๋Œ“๊ธ€ ์ˆ˜: 6
Jon
Jon 2020๋…„ 11์›” 19์ผ
I define it as a helper function in my script above

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

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

Jon
Jon 2020๋…„ 11์›” 19์ผ
You could do it like this
n = -10:10
x = zeros(length(n),1) % preallocate array of zeros to hold result
for k = 1:length(n)
% evaluate x(n)
x(k) = 2*usmpl(n(k)+ 1) - usmpl(n(k)-6);
end
% plot result
stem(n,x)
% define helper function
function delta = usmpl(n)
% define unit sample function
if n == 1
delta = 1
else
delta = 0
end
end
  ๋Œ“๊ธ€ ์ˆ˜: 6
Jon
Jon 2020๋…„ 11์›” 20์ผ
Great that your working on developing your skills, sounds like you have lots of talents, definitely post some new questions if you have more MATLAB questions. I've learned a lot from this site, there are a lot of knowledgeable people answering questions. By the way, you may already be beyond this, but if not the MATLAB On Ramp course is good for getting a quick start https://www.mathworks.com/learn/tutorials/matlab-onramp.html

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

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

SaiDileep Kola
SaiDileep Kola 2020๋…„ 11์›” 16์ผ
Hi Connor,
Start by copying complete code provided by Jon and usmpl is just a local function created to use. Don't use usmpl in the terminal without defining, that will solve your issue.
  ๋Œ“๊ธ€ ์ˆ˜: 7
Jon
Jon 2020๋…„ 11์›” 19์ผ
Oops now I feel kind of silly, didn't realize I had just continued my original comment. I will try to copy and paste into an answer.

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


Noor Hossen
Noor Hossen 2021๋…„ 7์›” 18์ผ
ํŽธ์ง‘: Noor Hossen 2021๋…„ 7์›” 18์ผ
(A).
Step 1. At first, needed to make a script file of delta function. It would be
Step 2. Then write another on script file following the problem statement
Output-----------

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by