Subtracting in matrix, column to column (Basic MatLab)?

2 次查看(过去 30 天)
Given a 45×48 matrix, type a single command that subtracts column 36 from column 44
i answered this but it pops up as Error: Invalid use of operator. Is there something wrong or should it be in different type of form.
(:,36)-(:,44)

采纳的回答

Star Strider
Star Strider 2019-8-11
Your idea is essentially correct. I have no idea what the question wants.
Perhaps providing a matrix and a reference to it will work:
A = rand(45,48);
col_dif = A(:,36)-A(:,44)
  6 个评论
John wick
John wick 2019-8-11
Ohhh Thank you very much for helping and explaining it. Love ya!

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2019-8-11
编辑:Image Analyst 2019-8-11
You need to put the matrix name in there, and a result variables, like
result = m(:,44) - .....................
etc.
  3 个评论
Image Analyst
Image Analyst 2019-8-11
Well you can't just have indexes within parentheses like (:,44), because how could MATLAB possibly know which matrix you're referring to.
John wick
John wick 2019-8-11
I guess i just got the idea on how it works but not really master it. Thank you for helping me out!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by