storage format using SPARSE and INT8

1 次查看(过去 30 天)
I'd like to save storage and time when I run my code. In order to do this I'm trying to modify the format-storage of some (1 0 -1) matrixes and in the follow example I note that int8 is the best. That's ok!
But if I try to save B as a sparse matrix (see the comment) I get the following error:
Undefined function 'sparse' for input arguments of type 'int8'.
1) So, is it possible to save a sparse matrix (made only with the values of element 1, 0 or -1) not with double precision, but with int storage-format to save too much storage?
2) In general, does making operation between different saved elements (for example the sum of matrix B with another matrix, but saved in double precision) create problems??
%Code.m
A = [1 0 0 0 0 0 0 0 0 0 0 0 0;
-1 0 0 0 0 0 0 0 0 0 0 0 1;
0 0 0 0 0 0 0 0 0 1 0 0 0];
B= int8(A);
C = sparse(A);
% D=sparse(B) <<<<<<<<<HERE THE COMMENT
whos A B C
-------------------------------------------------------------------------------------------------
%Command window shows
>> Code
Name Size Bytes Class Attributes
A 3x13 312 double
B 3x13 39 int8
C 3x13 176 double sparse

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sparse Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by