MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
A = int8(zeros(100));

This statement preallocates a 100-by-100 matrix of int8, first by creating a full matrix of
double values, and then by converts each element to int8. Creating the array as int8
values saves time and memory. For example:

A = zeros(100, 'int8');

See Also


Related Examples



  • “Reshaping and Rearranging Arrays”

  • “Preallocate Memory for Cell Array” on page 12-18

  • “Access Data Using Categorical Arrays” on page 8-30

  • “Preallocate Arrays of Graphics Objects”

  • “Construct Object Arrays”


More About



  • “Techniques to Improve Performance” on page 28-14


28 Performance

Free download pdf