reshape0, reshaping with padding or truncating

버전 1.0.0.0 (4.99 KB) 작성자: James Tursa
A c-mex routine for reshaping with padding or truncating
다운로드 수: 1.3K
업데이트 날짜: 2008/2/11

라이선스 없음

Reshapes an array like the MATLAB intrinsic reshape function. But reshape0 does not require that the total number of elements must remain the same. If the new array is larger, then it will be zero or blank padded. If the new array is smaller, then it will be a truncated version of the original. char arrays are padded with blanks, cell arrays are padded with empty double arrays, logical arrays are padded with false (zeros), and all other numeric arrays are padded with 0's. Structures cannot be padded or truncated (this feature is not yet implemented for the struct class ... maybe in a future version).

reshape0 is not as efficient as reshape when there is no truncating or padding involved because reshape0 will generally copy data whereas reshape will do a lazy copy.

Building (one-time only):

>> mex -setup
(then follow instructions to select a C / C++ compiler of your choice)
>> mex reshape0.c

That's it! Now you are ready to use reshape0.

In the unlikely case you get this error message:

bit16 define symbol is not a 16-bit integer

You will need to change the definition of the bit16 symbol in the reshape0.c file. You need to ensure that this is a 16-bit integer type for your system so that the MATLAB char class (which is 16 bits) will work properly. You might have to change the word "short" to something like int16_t or uint16_t to get it to work. Contact me and I will help.

인용 양식

James Tursa (2024). reshape0, reshaping with padding or truncating (https://www.mathworks.com/matlabcentral/fileexchange/18684-reshape0-reshaping-with-padding-or-truncating), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2006a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0