Does anyone knows an Answer to this question?

2 visualizaciones (últimos 30 días)
John wick
John wick el 9 de Ag. de 2019
Comentada: Neuropragmatist el 9 de Ag. de 2019
Mat Lab question.jpg
  3 comentarios
Alex Mcaulley
Alex Mcaulley el 9 de Ag. de 2019
Just do it and you will take away the uncertainty
John wick
John wick el 9 de Ag. de 2019
Thank you so much ><

Iniciar sesión para comentar.

Respuesta aceptada

Neuropragmatist
Neuropragmatist el 9 de Ag. de 2019
Editada: Neuropragmatist el 9 de Ag. de 2019
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 comentarios
Steven Lord
Steven Lord el 9 de Ag. de 2019
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.
Neuropragmatist
Neuropragmatist el 9 de Ag. de 2019
True, I could have been a bit clearer there.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by