Do the inverse operation of this reshape?

10 ビュー (過去 30 日間)
Davidra Fantarina ANDRIAMISAINA
Davidra Fantarina ANDRIAMISAINA 2018 年 2 月 13 日
回答済み: James Tursa 2018 年 2 月 13 日
I have this code and it works but i don't know how to do the inverse operation. str is a string
cle= uint8(str);
key= reshape(cle'-'0',1,[]);

回答 (2 件)

Roger Stafford
Roger Stafford 2018 年 2 月 13 日
編集済み: Roger Stafford 2018 年 2 月 13 日
You have to know the dimensions of the original array in order to get back to that, in which case you simply do a another ‘reshape’ to get there. That is, suppose size(A) = [4,7] and you do
A = reshape(A,14,2);
You can’t tell from the size of the new A that it was once 4-by-7, but if you know that it was, then
A = reshape(A,4,7)
will get you back there.
There is an overriding order in any array that 'reshape' does not alter, which is seen if you do this: A(:) for an array A. The order in A(:) will remain the same no matter how many reshapes are done on it. This is known as the array's "linear order".
  1 件のコメント
Davidra Fantarina ANDRIAMISAINA
Davidra Fantarina ANDRIAMISAINA 2018 年 2 月 13 日
It is not a matrix but a string with variable length

サインインしてコメントする。


James Tursa
James Tursa 2018 年 2 月 13 日
Are you just trying to recover an original single line string? E.g.,
str = char(key+'0');

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by