How do I multiply vector elements in the following fashion???

조회 수: 1 (최근 30일)
Maruti Patil
Maruti Patil 2016년 4월 2일
댓글: Maruti Patil 2016년 4월 2일
Suppose I have A=[18 44 20 55] & B=[4 6]
Now I want C=[18*4 44*4 20*6 55*6]
i.e I want to multiply first element of B with first pair of elements in A
and second element of B with second pair of A and so on...

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 2일
편집: Azzi Abdelmalek 2016년 4월 2일
A=[18 44 20 55]
B=[4 6]
out=reshape(bsxfun(@times,A',B),1,[])
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 2일
Then you have to reshape A
reshape(bsxfun(@times,reshape(A,2,2),B),1,[])

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by