필터 지우기
필터 지우기

extracting subset array from a cell array

조회 수: 10 (최근 30일)
Christian Chamberlayne
Christian Chamberlayne 2020년 4월 29일
답변: Ameer Hamza 2020년 4월 29일
I have data with multiple values at each location x y z. I have stored this as a cell array as follows.
DataPoint{x,y,z} = [V1, V2 , V3, V4, V5, V6];
DataPoint{2,3,4}(1) works to extract the value V1 at point 2,3,4.
I want to extract the values of V1 for all the points as a 3D array.
valuesV1 = DataPoint{ :, :, : }(1);
gives the following error: "Expected one output from a curly brace or dot indexing expression, but there were 1000 results."
1) everything is numeric, is there a different structure other than cell array that would be better?
2) what is the correct syntax for this?
3) should I just make a loop to do this or would that be slower?

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 29일
Use cellfun()
valuesV1 = cellfun(@(x) x(1), DataPoint);

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by