When I divide two matrix of the same size (5x1) I get a 5x5 matrix where the first column has the answer and the next 4 are zeros.

조회 수: 3 (최근 30일)
When I divide two matrix of the same size (5x1) I get a 5x5 matrix where the first column has the answer and the next 4 are zeros.
What am I doing wrong.
m1 = [2; 4; 5; 6; 9];
m2 = [1; 2; 5; 3; 3];
ans = m1 / m2;

채택된 답변

Jason Burke
Jason Burke 2021년 8월 10일
편집: Jason Burke 2021년 8월 10일
I wanted to divied each element by the corresponding element from the other matrix. I needed to perform the element by element division which is ./ instead of just /
ans = m1 ./ m2;

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by