Change all matrix elements from x to 1/x

14 次查看(过去 30 天)
Hello, i am trying to change all the elements in a single line matrix from Xj to 1/Xj. Thanks

采纳的回答

Rik
Rik 2018-6-12
X=1./X;
Use a dot for element-wise division and multiplication.
  3 个评论

请先登录,再进行评论。

更多回答(1 个)

Asieh Daneshi
Asieh Daneshi 2020-4-25
A=rand(n);
A(:,n)=1./A(:,n);
  1 个评论
Walter Roberson
Walter Roberson 2020-4-25
This would change a single column, rather than a single line (row). It happens to change the last column, by the way.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by