필터 지우기
필터 지우기

Divide all rows of an array by another array

조회 수: 2 (최근 30일)
Sumara
Sumara 2024년 5월 14일
답변: Image Analyst 2024년 5월 14일
Given an array
[3 -5 6 8;
5 8 10 -3;
6 8 3 4]
I want to divide each row based on a set of numbers
[1; 2; 3; 4]
to produce
[3/1 -5/2 6/3 8/4;
5/1 8/2 10/3 -3/4;
6/1 8/2 3/3 4/4]
or
[3 -2.5 2 2;
5 4 3.33 -0.75;
6 4 1 1]

채택된 답변

Image Analyst
Image Analyst 2024년 5월 14일
Use the automatic expansion capability:
m = [3 -5 6 8;
5 8 10 -3;
6 8 3 4];
columnVector = [1; 2; 3; 4]
columnVector = 4x1
1 2 3 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
output = m ./ columnVector'
output = 3x4
3.0000 -2.5000 2.0000 2.0000 5.0000 4.0000 3.3333 -0.7500 6.0000 4.0000 1.0000 1.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by