When multiplying or dividing a vector by a scaler, when do you need a period before the operator?
3 ビュー (過去 30 日間)
古いコメントを表示
This was a question I had, the picture of the problem and the correct answer is attached, thanks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1686481/image.png)
0 件のコメント
回答 (1 件)
Stephen23
2024 年 5 月 5 日
編集済み: Stephen23
2024 年 5 月 5 日
"When multiplying or dividing a vector by a scaler, when do you need a period before the operator?"
Lets consider multiplying.
There is no "period before the operator": this is the complete operator: .*
It is the operator for TIMES: https://www.mathworks.com/help/matlab/ref/times.html
This is another, different, complete operator: *
It is the operator for MTIMES: https://www.mathworks.com/help/matlab/ref/mtimes.html
You use MTIMES whenever you want to perform matrix multiplication of two matrices. If you do not know how matrix multiplication is defined then there are many tutorials online.
You use TIMES whenever you want to perform element-wise multiplication of array elements. As a rule of thumb, if you are not doing linear algebra then you probably want to use element-wise array operations.
The same basic concepts apply to multiplication, division, power:
Note that even though you asked about dividing a vector by a scalar, the screenshot you pasted actually shows dividing a scalar by a vector. Getting things mixed up makes writing and understanding code much harder.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!