How do I retrieve a specific range of values from a cell?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jesse Finnell
am 31 Okt. 2019
Bearbeitet: Turlough Hughes
am 31 Okt. 2019
I have a 1x4 cell that contains 685x1 doubles and I need to plot certain ranges that are contained inside cells. For example, I want to plot rows 15-25 of cell 1 and 4.
0 Kommentare
Akzeptierte Antwort
Turlough Hughes
am 31 Okt. 2019
Bearbeitet: Turlough Hughes
am 31 Okt. 2019
Let's say your cell is called data and this is a 1 by 4 cell array with each cell containing column vectors of size 685 x 1. You can access the data directly using the following code:
data{1,1}(15:25,1)
data{1,2}(15:25,1)
data{1,3}(15:25,1)
data{1,4}(15:25,1)
You could also take rows 15:25 from each cell in your cell array as follows:
numarray=cell2mat(cellfun(@(x) x(15:25), data, 'UniformOutput', false))
plot(numarray)
TLDR;
If your cells are always the same size you can do the following:
numarray=cell2mat(data);
plot(numarray(15:25,:))
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!