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

1 visualización (últimos 30 días)
John wick
John wick el 11 de Ag. de 2019
Comentada: John wick el 11 de Ag. de 2019
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)

Respuesta aceptada

Star Strider
Star Strider el 11 de Ag. de 2019
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 comentarios
John wick
John wick el 11 de Ag. de 2019
Ohhh Thank you very much for helping and explaining it. Love ya!
Star Strider
Star Strider el 11 de Ag. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 11 de Ag. de 2019
Editada: Image Analyst el 11 de Ag. de 2019
You need to put the matrix name in there, and a result variables, like
result = m(:,44) - .....................
etc.
  3 comentarios
Image Analyst
Image Analyst el 11 de Ag. de 2019
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 el 11 de Ag. de 2019
I guess i just got the idea on how it works but not really master it. Thank you for helping me out!

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by