How can I reshape a matrix into a square?

1 view (last 30 days)
Grant
Grant on 29 Oct 2013
Answered: Image Analyst on 29 Oct 2013
How can I reshape a matrix into a square by deleting rows/columns, but cannot use loops or if statements, example: 4x6 into a 4x4 or 3x2 into a 2x2?

Answers (1)

Image Analyst
Image Analyst on 29 Oct 2013
If you have the Image Processing Toolbox, you can use imresize()
out = imresize(originalMatrix, [desiredRows, desiredColumns]);
Or you can use interp2().

Products

Community Treasure Hunt

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

Start Hunting!