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 visualizaciones (últimos 30 días)
please can someone offer a help to this.Thank you as you volunteer.

Respuestas (1)

KSSV
KSSV el 21 de Ag. de 2017
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:

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by