Q:

Which is faster: using false or using logical(0) to preallocate a matrix to all logical zeros? Write a script to test this

0

Which is faster: using false or using logical(0) to preallocate a matrix to all logical zeros? Write a script to test this. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch5Ex34.m

% Test to see whether logical(0) or false is faster

fprintf('Start with logical(0)\n\n')

tic

mat(1:100, 1:100) = logical(0);

toc

fprintf('Now for false \n\n')

tic

mat2(1:100, 1:100) = false;

toc

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now