cell multiplication with a vector

조회 수: 1 (최근 30일)
David Kusnirak
David Kusnirak 2013년 6월 13일
Hi,
I have a cell structure (Aa), where each cell is a square sparse matrix and I need to multiply each cell with a vector (fi) to produce a matrix Aaf.
my code to do this is:
Aaf=zeros(numel(sig),length(Aa));
for j=1:length(Aa);
Aaf(:,j)=Aa{j}*fi;
end
but it seems to be pretty ineffective, so I' ve tried to evaluate it using a cellfun, but it doesn't work
Aaf_test = cellfun(@(x) x * fi(:,1),Aa);
Does anybody know ho do the multiplication faster than the for loop?
thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 13일
Aaf_test = cellfun(@(x) x * fi,Aa,'un',0);
  댓글 수: 1
David Kusnirak
David Kusnirak 2013년 6월 13일
it works well thanks, but yields even worse performance, than the for loop..shame

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by