フィルターのクリア

How to write a matrix with a variable inside it?

1 回表示 (過去 30 日間)
Muhammad Syauqi
Muhammad Syauqi 2024 年 4 月 9 日
編集済み: Voss 2024 年 4 月 9 日
I'm trying to write this matrix
B = [ 0 1 2x 3x^2] but matlab suggest that it should be written like B = [0 1 2*x 3*x^2]
then when I try to transpose or to do anything with it it said unrecognized function or variable 'x'

採用された回答

Voss
Voss 2024 年 4 月 9 日
編集済み: Voss 2024 年 4 月 9 日
Do you mean for x to be a symbolic variable?
syms x
B = [0 1 2*x 3*x^2]
B = 
B.'
ans = 
Or for x to be a numeric variable?
x = 2.2;
B = [0 1 2*x 3*x^2]
B = 1x4
0 1.0000 4.4000 14.5200
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
B.'
ans = 4x1
0 1.0000 4.4000 14.5200
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Either way, you have to define x before you use it.
  2 件のコメント
Muhammad Syauqi
Muhammad Syauqi 2024 年 4 月 9 日
thanks for the answer I understand now :)
Voss
Voss 2024 年 4 月 9 日
編集済み: Voss 2024 年 4 月 9 日
You're welcome! Any questions, let me know.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by