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.
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
please can someone offer a help to this.Thank you as you volunteer.
1 Kommentar
Antworten (1)
KSSV
am 21 Aug. 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:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!