multiply vector and matrix
显示 更早的评论
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
2020-8-12
Wanted = cellfun(@times, a, b, 'un', 0);
celldisp(Wanted)
madhan ravi
2020-8-12
编辑:madhan ravi
2020-8-12
Wanted = cell2mat(a) .* cell2mat(b);
celldisp(num2cell(Wanted, 2))
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!