Accessing elements of an array of lists

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 Comments

Is your array a row vector or a matrix? Find it by typing size(V3PH).
Turned out it was indeed a matrix.

Sign in to comment.

 Accepted Answer

V3PH(:, 2)
provided that your "vectors" are not cell arrays.
If your vectors are cell arrays then
cellfun(@(c)c(:,2), V3PH)

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!