フィルターのクリア

When do I need point operator when using power function?

31 ビュー (過去 30 日間)
x y
x y 2013 年 10 月 26 日
コメント済み: Steven Lord 2022 年 1 月 26 日
I want to know ,how can I know when is the point(dot) use in power,when I want to calculate something.
In matrix calculation is always need the . ?
You how to decide use or not use the point
a.^4 a^4

採用された回答

Zack Peters
Zack Peters 2013 年 10 月 26 日
The '.' syntax is used to denote element-wise multiplication. What this means is that each element of variable 'a' will be raised to the power of 4 rather than have the entire variable 'a' raised to the power of 4.
If 'a' were to be a single value then it doesn't make any difference. However, if 'a' were a matrix then you can begin to see the difference in output of the element-wise operator
~Zack
  2 件のコメント
Mohammed Hamdalla
Mohammed Hamdalla 2022 年 1 月 26 日
thank you man that really helped.
Steven Lord
Steven Lord 2022 年 1 月 26 日
As a concrete example:
A = [1 2; 3 4]
A = 2×2
1 2 3 4
B = A.*A % Multiply each element of A by itself, element-wise
B = 2×2
1 4 9 16
B2 = A.^2 % Same as B
B2 = 2×2
1 4 9 16
C = A*A % Perform matrix multiplication
C = 2×2
7 10 15 22
C2 = A^2 % Same as C
C2 = 2×2
7 10 15 22
% Elements of C are the dot product of the corresponding rows and columns of A
C(1, 2) == dot(A(1, :), A(:, 2)) % true
ans = logical
1

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by