Accessing elements of an array of lists

조회 수: 3 (최근 30일)
Colin Mariuz
Colin Mariuz 2020년 10월 23일
댓글: Colin Mariuz 2020년 10월 24일
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
Freewing
Freewing 2020년 10월 24일
Is your array a row vector or a matrix? Find it by typing size(V3PH).
Colin Mariuz
Colin Mariuz 2020년 10월 24일
Turned out it was indeed a matrix.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 24일
V3PH(:, 2)
provided that your "vectors" are not cell arrays.
If your vectors are cell arrays then
cellfun(@(c)c(:,2), V3PH)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by