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

조회 수: 1 (최근 30일)
John wick
John wick 2019년 8월 11일
댓글: John wick 2019년 8월 11일
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!
Star Strider
Star Strider 2019년 8월 11일
As always, my pleasure!

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

추가 답변 (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에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by