create empty logical variable in matlab

To create an empty logical variable in MATLAB, you can use the following code:

main.m
empty_logical = logical([]);
29 chars
2 lines

This creates an empty logical variable named empty_logical. The logical([]) syntax creates a 0x0 logical array, which is empty. You can add values to this variable later by indexing into it and assigning values, like so:

main.m
empty_logical(1) = true;
25 chars
2 lines

This would add a value of true to the empty logical variable at the first index.

related categories

gistlibby LogSnag