필터 지우기
필터 지우기

change numbering inside cell

조회 수: 1 (최근 30일)
NA
NA 2019년 10월 2일
답변: Akira Agata 2019년 10월 2일
I have
B=[1,1;2,2;3,40;4,10;5,15;6,19;7,22];
c={[1,10,15],[15,19,22],[1,2,40]};
Matrix B shows that 4 is correspond to10 or 7 correspond to 22 or 3 correspond to 40 .
So I want to change c according to second column of B
result should be
c_new={[1,4,5],[5,6,7],[1,2,3]};

채택된 답변

Akira Agata
Akira Agata 2019년 10월 2일
Solution 1:
c_new = cell(size(c));
for kk = 1:numel(c)
c_new{kk} = interp1(B(:,2),B(:,1),c{kk});
end
Solution 2:
% "Solution 1" in 1 line
c_new = cellfun(@(x) interp1(B(:,2),B(:,1),x),c,'UniformOutput',false);

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by