function reshape creating matrix

1 Ansicht (letzte 30 Tage)
Thomas Kozinski
Thomas Kozinski am 11 Mär. 2021
Beantwortet: Alan Stevens am 11 Mär. 2021
Hi, I need to use the reshape command to create a 3 × 4 matrix and fill it with the next values starting from 10.
A = 10:20;
B = reshape(A,[3,4])
I'm trying to do it with what command but I get an error: To RESHAPE the number of elements must not change. How to do it correctly?

Akzeptierte Antwort

Alan Stevens
Alan Stevens am 11 Mär. 2021
"A" only has 11 elements. You want B to have 12 elements (3*4). If you set A = 10:21, for example, it will work.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping 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