how to write a program to plot the signal {1, 2, 3, 4, 5} and also how to Represent this sequence x(n) = {0, 1, 2, 3, 4, 5}. in MATLAB.

11 次查看(过去 30 天)
please can someone offer a help to this.Thank you as you volunteer.

回答(1 个)

KSSV
KSSV 2017-8-21
What ever come sin flower braces ({}) is a cell in MATLAB. A matrix comes in square braces ([]). You can check the class of the variable using class. It is better to have a matrix for calculations and plotting. YOu can plot your signal as below:
mysignal = {1 2 3 4 5} ; % it is a cell (check with _class(mysignal)_)
mysignal = cell2mat(mysignal) % convert to matrix using _Cell2mat_
plot(mysignal) % plot using _plot_
Coming about the next question; regaridng sequence. If you have all same vectors, save them in a matrix. Like below:
X = zeros(5,5) ;
for i = 1:5
X(i,:) = rand(1,5) ;
end
If your sequence is having different sized vectors, save them into cell. Like below.
X = cell(3,1) ;
X{1} = rand(!,5) ;
X{2} = rand(1,7) ;
X{3} = rand(5,1) ;
MATLAB is easy with rich documentation. REad about matrix indexing:

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by