I've a cell_array of data, the dimension is 'Cell_P' 10x1, inside every cell there is a matrix 25x16. I need six columns of the matrix, and I can find these because I know the values of parameters inside. I need to make a new cell_array with inside 10 matrix 25x6.
I would like insert as input six values, identify the columns where the values are, create a new cell_array with just that column.
How can I do it?

댓글 수: 2

try
Cell_P{:}
An example of inputs and desired outputs would be helpful.
That said, I would guess that something like this is what you're going for, tweaked as appropriate for your exact data types and structures.
%If your inputs are numerical
cellIndex = cellfun(@(x) ismember(x,myInputValues),inputCellArray(1,:));
outputArray = inputCellArray(:,cellIndex);
%if your inputs are strings
cellIndex = ismember(inputCellArray(1,:),myInputValues);
outputArray = inputCellArray(:,cellIndex);

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

 채택된 답변

Stephen23
Stephen23 2016년 2월 22일
편집: Stephen23 2016년 2월 22일

0 개 추천

Try this:
% fake data:
for k = 10:-1:1
inp{k} = repmat(randperm(16),25,1);
end
% extract only columns that contain an element in vec:
vec = [2,3,6,9,11,14];
out = inp;
for k = 1:numel(out)
out{k} = out{k}(:,any(ismember(out{k},vec),1));
end

댓글 수: 1

Lunatix
Lunatix 2016년 2월 23일
Oh my god! thanks! I don't know how, but works!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

질문:

2016년 2월 22일

댓글:

2016년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by