필터 지우기
필터 지우기

multiply vector and matrix

조회 수: 2 (최근 30일)
Ido Gross
Ido Gross 2020년 8월 12일
편집: madhan ravi 2020년 8월 12일
Hi!
I have a matrix such as:
a = [1 1 1]
[2 2 2]
[3 3 3]
and a vector:
b = [2]
[2]
[2]
I want to multiply them so i'll get:
a*b = [2 2 2]
[4 4 4]
[6 6 6]
How can I do it in matlab?
thanks!

답변 (3개)

madhan ravi
madhan ravi 2020년 8월 12일

madhan ravi
madhan ravi 2020년 8월 12일
Wanted = cellfun(@times, a, b, 'un', 0);
celldisp(Wanted)

madhan ravi
madhan ravi 2020년 8월 12일
편집: madhan ravi 2020년 8월 12일
Wanted = cell2mat(a) .* cell2mat(b);
celldisp(num2cell(Wanted, 2))

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by