Calculating input matrix to Upper triangular matrix

3 visualizaciones (últimos 30 días)
DooDoo
DooDoo el 3 de Oct. de 2012
I have to write a code that will calculate a matrix, A, to upper triangular matrix, U. I am stuck as soon as I opened the matlab because I have no idea how to utilize the software. I just have some few questions, so I can get started.
1. How do write a code so that the matrix becomes an input? For example, I need the matrix to be a square or return an error so I wrote the code:
if m ~= n
error('Matrix is not square')
end
but I don't know how to assign the input matrix into the variable.
Would someone help me please?
Thank you

Respuesta aceptada

Matt Fig
Matt Fig el 3 de Oct. de 2012
A = magic(5);
[m,n] = size(A)
You might want to look at the TRIU function.
  2 comentarios
DooDoo
DooDoo el 3 de Oct. de 2012
i actually have to use loop function (for), if, size, and rank to do elimination. I can't use a command to let it solve it for me :/
So if I want to check if any matrix is square, what would I use?
Matt Fig
Matt Fig el 3 de Oct. de 2012
Daniel, look at the code I gave you. Maybe even run it in MATLAB. If you don't know what the SIZE function does, read this:
help size
Then write some code and show what you have done. People here generally will help with homework, but expect to see some time put in by the asker. Once you show that you have tried, then ask a specific question like, "I want to set a particular element of an array to zero, how do I do that?"

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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