行列の範囲指定の書き方

20 visualizaciones (últimos 30 días)
彩乃
彩乃 el 14 de Nov. de 2023
Comentada: Atsushi Ueno el 14 de Nov. de 2023
f=10*x(1,:)+5*(2,:)
のx(1,:)と(2,:)に出てくる数値を0.1から10に範囲を設定したい時、xmとxMはそれぞれどのように書けばいいですか?
  2 comentarios
Dyuman Joshi
Dyuman Joshi el 14 de Nov. de 2023
What is the objective here?
What are xm and xM?
Atsushi Ueno
Atsushi Ueno el 14 de Nov. de 2023
どういう状況ですか?目一杯想定してみましたが、何を計算したいのか良くわかりません
x = 20 * rand(2,10) - 5 % 適当な値で行列 x を作成(xの範囲は-5~15)
x = 2×10
2.6424 0.1530 4.9814 0.8633 0.8156 7.3554 13.2246 2.6418 -4.6864 6.9958 11.1236 3.5038 7.7657 -0.2480 3.9032 -2.6194 3.9562 2.1639 5.7136 12.9850
temp = 0.1 <= x & x <= 10 % 0.1~10 の要素に 1 、それ以外に 0 をインデックス付け
temp = 2×10 logical array
1 1 1 1 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 0
xm = temp(1,:) % 1行目の0.1~10インデックスがxmで、
xm = 1×10 logical array
1 1 1 1 1 1 0 1 0 1
xM = temp(2,:) % 2行目の0.1~10インデックスがxMという事ですか?
xM = 1×10 logical array
0 1 1 0 1 0 1 1 1 0
f = 10 * x(1,xm) + 5 * x(2,xM) % 0.1~10の要素数が合わないから加算出来ません!
Arrays have incompatible sizes for this operation.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!