Does anyone knows an Answer to this question?

2 次查看(过去 30 天)
Mat Lab question.jpg

采纳的回答

Neuropragmatist
Neuropragmatist 2019-8-9
编辑:Neuropragmatist 2019-8-9
Well let's think about it a little, in Matlab the multiplication sign (i.e. 5 x 5 = 25) is represented by an asterisk (*). Generally, if you have 2 numbers the asterisk will work the same as a multiplication:
5*5
ans = 25
However, when you have vectors or matrices this performs matrix multiplication which 99% of the time is probably not what you want unless you work with linear algebra, I can't really easily explain it here but you can read about it here. Instead you will probably want element-wise multiplication where each number in the matrix is multiplied by the corresponding number in the other matrix. To do that you have to put a full stop (.) before the asterisk to indicate that's what you want, like this:
[1 2 3 4].*[1 2 3 4]
ans = 1 4 9 16
Here each element of the left matrix has been multiplied by the element of the right matrix in the same position.
So let's look at your problem, the 1st answer will throw an error because the full stop is after the asterisk not before and Matlab doesn't know what to do with that. The 4th option is also not proper syntax (unless it is supposed to represent A*B which is the same as the 2nd option or [A B] which will not give anything like the answer).
So that leaves the 2nd and 3rd options, why don't you try them out in Matlab yourself, just run this code:
A = [0 6;3 5]
B = [7 6;9 3]
A*B
A.*B
But, if the second answer is correct you can easily work out in your head what it will look like, for instance the top right element of C would be the top right element of A (6) multiplied by the top right element of B (also 6)...
More generally, if you really need help with this homework you should probably read this:
Hope this helps,
M.
  2 个评论
Steven Lord
Steven Lord 2019-8-9
The 4th option is also not proper syntax
To nitpick slightly, it is a valid reference to a function named AB with no input arguments or a variable named AB so I wouldn't call it "not proper syntax". But since the problem statement doesn't mention either a function or variable by that name and there is no built-in MATLAB function named AB, I agree that this isn't the answer. It is there to trip people up if they assume MATLAB performs implicit multiplication.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by