Matrix division "in scalar way"

29 次查看(过去 30 天)
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!

采纳的回答

Alan Stevens
Alan Stevens 2020-8-31
X = Y ./ (Z .* 2);
Note the dot by the divide sign.
  2 个评论
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