Accessing elements of an array of lists
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
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 Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!