Matrix division "in scalar way"

조회 수: 14 (최근 30일)
Mateusz Brzezinski
Mateusz Brzezinski 2020년 8월 31일
댓글: madhan ravi 2020년 8월 31일
Hello,
I have following formula
X=Y/(Z*2);
Where
Y is a vector predefined 1x200 - let say 1, 2, 3, 4, 5 .... 200
Z is also a vector predefined 1x200 - let say 1, 2, 3, 4, 5 .... 200
If I run it in sacalar I should always get 0.5 (1/(1*2) = 2/(2*2) =...= 200/(200*2)
I would like to get this same kind of results but stored in 1x200 array/vector when I run it as a matrix operation.
So X = [0,5 , 0,5 , .... 0,5]
How to do that?
If I run it like:
X=Y/(Z.*2);
I only get single result
and If I run it like:
X=Y\(Z*2);
I got a nonsense 200x200 matrix.
I will be thankful for any tips!
  댓글 수: 1
Stephen23
Stephen23 2020년 8월 31일
편집: Stephen23 2020년 8월 31일
"I got a nonsense 200x200 matrix."
It is not nonsense, you just used the wrong operation:

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

채택된 답변

Alan Stevens
Alan Stevens 2020년 8월 31일
X = Y ./ (Z .* 2);
Note the dot by the divide sign.
  댓글 수: 2
Mateusz Brzezinski
Mateusz Brzezinski 2020년 8월 31일
Thanks!
madhan ravi
madhan ravi 2020년 8월 31일
Read the link KSSV and Stephen Cobeldick links, by the way .* is simply *

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

추가 답변 (1개)

KSSV
KSSV 2020년 8월 31일
편집: KSSV 2020년 8월 31일

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by