# 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.

14 visualizzazioni (ultimi 30 giorni)
Theman JIrnadu il 20 Ago 2017
Risposto: KSSV il 21 Ago 2017
please can someone offer a help to this.Thank you as you volunteer.
##### 1 CommentoMostra NessunoNascondi Nessuno
Jan il 20 Ago 2017
The question is not clear. How should the plot look like? What is "n"?

Accedi per commentare.

### Risposte (1)

KSSV il 21 Ago 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) ;
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Annotations in Help Center e File Exchange

### Tag

Non è stata ancora inserito alcun tag.

### Community Treasure Hunt

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

Start Hunting!