I want to subtract two different arrays from each other. how can ı do?

조회 수: 51 (최근 30일)
studentmatlaber
studentmatlaber 2021년 4월 22일
댓글: Rik 2021년 4월 23일
I have two TV series. An array consists of 1 column and 5 rows. My B array consists of 50 columns and 5 rows. What I want here is to subtract the value of an array in row 1 column 1 from all elements of array B in row 1. And he continues this process in turn. I tried this code for this, but it doesn't work correctly. I will be glad if you help me.
for i = 1: 5
C = B (i, :) - A (i, 1);
end
  댓글 수: 1
Rik
Rik 2021년 4월 23일
Backup:
I want to subtract two different arrays from each other. how can ı do?
I have two TV series. An array consists of 1 column and 5 rows. My B array consists of 50 columns and 5 rows. What I want here is to subtract the value of an array in row 1 column 1 from all elements of array B in row 1. And he continues this process in turn. I tried this code for this, but it doesn't work correctly. I will be glad if you help me.
for i = 1: 5
C = B (i, :) - A (i, 1);
end

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

답변 (1개)

Walter Roberson
Walter Roberson 2021년 4월 22일
A = randi(9, 5, 1)
A = 5×1
8 3 2 9 8
B = randi(9, 5, 10)
B = 5×10
7 8 2 5 8 9 9 3 4 3 9 9 9 5 3 6 2 2 6 1 4 1 5 9 2 4 4 5 4 9 6 9 1 9 7 2 8 4 4 9 7 1 2 1 7 2 5 4 3 3
B - A
ans = 5×10
-1 0 -6 -3 0 1 1 -5 -4 -5 6 6 6 2 0 3 -1 -1 3 -2 2 -1 3 7 0 2 2 3 2 7 -3 0 -8 0 -2 -7 -1 -5 -5 0 -1 -7 -6 -7 -1 -6 -3 -4 -5 -5

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by