如何将两行或两列相乘? [英] How to multiply two rows or columns?

查看:337
本文介绍了如何将两行或两列相乘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

a = [1, 2, 3];
b = [3, 2, 1];
c = a * b;

收益

错误:运算符*:参数不一致(op1为1x3,op2为1x3)

error: operator *: nonconformant arguments (op1 is 1x3, op2 is 1x3)

为什么不能将这两个相同大小的行相乘? 我不需要为此运行一个for循环,但是我不知道另一种方式...

Why can I not multiply these two rows of the same size? I shouldn't have to run a for loop for this, but I don't know of another way...

我看到了第1.2.3节,这(至少对我而言)表明我应该能够做到.

I saw section 1.2.3 here, which indicates (to me at least) that I should be able to do it.

推荐答案

我现在看到有一个.*运算符.我不知道在文档中哪里可以找到它,而它确实可以满足我的需求.

I see now that there is a .* operator. I did not know where to find that in the documentation, and it does what I want.

这篇关于如何将两行或两列相乘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆