行列の範囲指定の書き方

조회 수: 20 (최근 30일)
彩乃
彩乃 2023년 11월 14일
댓글: Atsushi Ueno 2023년 11월 14일
f=10*x(1,:)+5*(2,:)
のx(1,:)と(2,:)に出てくる数値を0.1から10に範囲を設定したい時、xmとxMはそれぞれどのように書けばいいですか?
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 11월 14일
What is the objective here?
What are xm and xM?
Atsushi Ueno
Atsushi Ueno 2023년 11월 14일
どういう状況ですか?目一杯想定してみましたが、何を計算したいのか良くわかりません
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!