Vectorizing Value Assignment to an Array of Structures

Posted on Nov 7, 2015

MATLAB code:
% create an array of 100 structures
chan = struct('Index', num2cell(1:100));

% assign new numbers (larger by 3) to the Index field without using a loop

% Method 1
chan = arrayfun(@(s) setfield(s,'Index', s.Index + 3), chan);

% Method 2: This is faster than Method 1, but requires a temporary variable.
new_index = num2cell([chan.Index] + 3);
[chan.Index] = new_index{:};

% Method 3: Surprisingly using a loop is the fastest!!!
for m=1:100, chan(m).Index = chan(m).Index + 3; end

% The fastest time out of 10 runs on my desktop with R2015b
% Method 1: Elapsed time is 0.002056 seconds.
% Method 2: Elapsed time is 0.000357 seconds.
% Method 3: Elapsed time is 0.000124 seconds.

Thunderbird Command Error 12

Posted on Jul 31, 2015


Thunderbird shows a popup that says, “The current operation on ‘Inbox(or one of your folders)’ did not succeed. The mail server for account (your account name) responded: Command Error. 12.”, when it tries to access an IMAP account.

The error happens with some servers that does not support “ID command”.

Go [Option] – [Advanced], click [Config Editor] and fnd the following pref.


It is true by default. Toggle it to false by double-clicking on it. Close the editor and restart Thunderbird.

How to clear Cache Partition on Moto G (or Moto X)

Posted on Jun 18, 2015


This will remove any temporary files that may be causing the problem, but will not delete your files or settings.

1. With the phone powered off, press the VOL DOWN KEY for 2-3 seconds then POWER key then release.
2. The device will display different BOOT OPTIONS
3. Use the VOL DOWN Key to SCROLL to Recovery and VOL UP Key to select
Tip: If the device reboots, you may have waited to long to make a selection, you will need to begin the process again.
4. The device will display the Motorola logo and then the Android in distress ( logo with Exclamation mark)
5. Press and hold the VOL UP key for 10-15 seconds. While still holding the VOL UP key tap and release the POWER key
Tip: You can try this step, holding the phone in landscape. If you are stuck on step 6, try a force reboot by pressing the Power key and Vol Down key, and start the process again.
6. The device will display additional menu options (Text will appear in BLUE)
7. Use the VOL DOWN Key to scroll to wipe cache partition and the POWER Key to select this option
8. The device will then perform the partition wipe
9. The device will reboot and start the normal power up sequence