Hello,
I have a report due in two days and have no idea how to plot this sequence. I know almost nothing about Matlab and my tutors as usual have been no help at all.
If some one can help me out here I would greatly appriciate it.
The sequence is:
𝑥(𝑛) = {… , 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, … }
Cheers

2 件のコメント

Mario van Rooij
Mario van Rooij 2020 年 11 月 27 日
Where does the n come into play? What do you want to plot when n = 10 for example?
Connor Wright
Connor Wright 2020 年 11 月 27 日
I want to plot −20 ≤ 𝑛 ≤ 12.

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2020 年 11 月 27 日

0 投票

The mod function and the colon,: operator are your friends!

6 件のコメント

Connor Wright
Connor Wright 2020 年 11 月 27 日
How would I implement the mod function?
Star Strider
Star Strider 2020 年 11 月 27 日
Example —
x = 0:30;
y = mod(x, 15);
figure
plot(x, y)
grid
I leave the rest to you!
Connor Wright
Connor Wright 2020 年 11 月 27 日
Right first off thank you for putting me on the right path, however I have staryed off it and went down a different route and have run into trouble. my code is below and I keep getting the sam error of 'error using plot vectors must be the same length'
n = -20:12
x = repmat([5,4,3,2,1],3,15)
linspace = x
plot(n,x)
Error using plot
Vectors must be the same length
Any ideas?
Star Strider
Star Strider 2020 年 11 月 27 日
Use the colon operator with the ‘n’ vector, and then operate on it to create the triangular pulses.
That will eliminate the vector length problem.
Connor Wright
Connor Wright 2020 年 11 月 27 日
I really am sorry about this but I dont understand what you mean.
Star Strider
Star Strider 2020 年 11 月 27 日
Please experiment!
Use my example as a guide, and carefully read the documentation for colon. Note how to use it to code a descending sequence.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索

製品

リリース

R2020b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by