MATLAB ヘルプ センター
Variable creation and indexed assignment
B = A
B(i,j,...) = A
B = A stores the value of A in the variable B.
A
B
The = character assigns a value to a variable, whereas the == character compares the elements in two arrays.
=
==
example
B(i,j,...) = A assigns the elements of A to the indexed elements of B specified by the indexing expression B(i,j,...).
B(i,j,...)
expand all
Use the = sign to assign a value to a variable.
A = 2
Because A has a single element, it is a scalar. Assign multiple values to a variable to create a vector or matrix.
B = [2 4 6 8]
B = 1×4 2 4 6 8
C = [1 0; 0 1]
C = 2×2 1 0 0 1
You also can assign the contents of one variable to another. For example, overwrite the scalar stored in A with the vector in B.
A = B
A = 1×4 2 4 6 8
Create a 3-by-3 matrix, and then index the first row to assign new elements.
A = [1 2 3; 4 5 6; 7 8 9]
A = 3×3 1 2 3 4 5 6 7 8 9
A(1,:) = [10 10 10]
A = 3×3 10 10 10 4 5 6 7 8 9
With indexed assignment, the number of elements indexed on the left side must equal the number of new elements on the right side.
Introduced before R2006a
== | ( )
( )
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
ヨーロッパ
アジア太平洋地域
最寄りの営業オフィスへのお問い合わせ