Accessing elements of an array of lists
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Colin Mariuz
am 23 Okt. 2020
Kommentiert: Colin Mariuz
am 24 Okt. 2020
Hi,
I am using MATLAB in conjuction with simulation software that grants an array of data in the form "domain, E1, E2, E3". The array is about 200k elements long, with each of these 4 variables per element.
ex. V3PH = [domain1,E11,E21,E31
domain2,E12,E22,E32
domain3, E13, E23, E33
domain4, E14, E24, E34,
etc....]
If I am looking to create an array of all the E1 element only.. How would I do this?
Ive tried using the following code:
for n=1:200000
Va(n) = V3PH(n:1:2); %Array from all E1 elements
....
....
end
I know the indexing isn't correct in the above code, but I'd appreciate some tips on how to achieve this. Thanks.
2 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Okt. 2020
V3PH(:, 2)
provided that your "vectors" are not cell arrays.
If your vectors are cell arrays then
cellfun(@(c)c(:,2), V3PH)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!