필터 지우기
필터 지우기

affect values to cells without a loop

조회 수: 1 (최근 30일)
Christophe
Christophe 2015년 7월 9일
편집: Azzi Abdelmalek 2015년 7월 9일
I have the following cells :
a{1}=zeros(1,3);
a{2}=zeros(1,4);
ii{1}=1;
ii{2}=3;
b{1}=2;
b{2}=3;
How can I set a{1}(ii{1})=b{1}; and a{2}(ii{2})=b{2}; without a loop ? (for example using cellfun) Thanks

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 9일
편집: Azzi Abdelmalek 2015년 7월 9일
a{1}=zeros(1,3);
a{2}=zeros(1,4);
ii{1}=1;
ii{2}=3;
b{1}=2;
b{2}=3;
out=cellfun(@(x,y,z) [x(1:y-1) z x(y+1:end)],a,ii,b,'un',0)
But you should know that a for loop is faster then using cellfun

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by