Filter löschen
Filter löschen

vectorized code to make square matrix from nxm matrix

1 Ansicht (letzte 30 Tage)
David Phung
David Phung am 16 Nov. 2014
Kommentiert: David Phung am 16 Nov. 2014
Hey so the problem I have is that I am supposed to make a square matrix from an mxn matrix (2x4 or 4x9 etc). Basically what the code will do is delete the first row or column until it becomes a square matrix. The catch is that i cannot use if statements.. which makes this harder.
My idea before i saw that i couldnt use if statements was check if r = c then eliminate rows or columns depending on which one is bigger using A(:,c-r)=[]; if that would work.
I erased my code with the if statement after i read that part ( I got overzealous and didnt finish reading the question). Does anyone have any tips to help me?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 16 Nov. 2014
  3 Kommentare
David Phung
David Phung am 16 Nov. 2014
Ahh that makes sense. Thank you so much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Sparse Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by