Another SQLite interface for MATLAB

Posted on Jun 17, 2015

This MEX package enables MATLAB to access SQLite databases via SQL queries. I wrote it because previous solutions did not do what I wanted in a simplistic way. The zip file below contains source code and 32-bit & 64-bit binaries for MS Windows.

Download: sqlite.zip (2.32MB)

The code was tested with SQLITE 3.11.0, MATLAB 2015b and Visual Studio Community 2015. You may need to install Visual C++ Redistributable Packages for Visual Studio 2015 from the Microsoft website to run the included MEX binaries. This program is distributed in the hope that it will be useful, but without any warranty.

Usage:
db = sqlite;  % create a class object
db.version    % SQLite version
db.connect('test.db');
db.query('CREATE TABLE Test (Subject TEXT, Score INTEGER);');
db.query('INSERT INTO Test (Subject,Score) VALUES (''English'',50);');
db.query('INSERT INTO Test (Subject,Score) VALUES (?,?);','Math',90); % bind parameter
db.query('UPDATE Test SET Score=80 WHERE Subject=''English'';');
table = db.query('SELECT * from Test;');
db.query('DELETE FROM Test WHERE Score<90;');

cell_mat = { uint8('A byte stream in a cell matrix is considered a blob.') };
db.query('CREATE TABLE BinaryLargeOBject (Object BLOB);');
db.query('INSERT INTO BinaryLargeOBject (Object) VALUES (?);',cell_mat); % handle blob

clear db;  % This also disconnect DB

“S1023” error when you install the DirectX SDK (June 2010)

Posted on May 8, 2015

From https://support.microsoft.com/en-us/kb/2728613

Cause
The issue occurs because a newer version of the Visual C++ 2010 Redistributable is present on the computer. The June 2010 DirectX SDK installs version 10.0.30319 of the Visual C++ Redistributable.

Resolution
1. Uninstall Microsoft Visual C++ 2010 x86 & x64 Redistributable.
2. Install the June 2010 DirectX SDK.
3. Reinstall the most current version of the Visual C++ 2010 Redistributable Package.

How to execute daqregister(‘nidaq’) without running MATLAB as administrator

Posted on May 6, 2015

In order to control NI devices with Data Acquisition Toolbox in MATLAB, you first need to run MATLAB as administrator and execute the DAQREGISTER command. (See this.) However, running MATLAB as administrator is not possible, if you have to log in with a different username to be an administrator and your MATLAB activation type is Standalone Named User. MATLAB just won’t start when you switch to your admin account, because the Standalone Named User license does not allow anyone to use MATLAB but the licensed named user. You can bypass this problem by giving your non-admin MATLAB user write permission for the following two registry entries so that you can execute DAQREGISTER as a standard user. This was tested on 64-bit Windows 7 with MATLAB 2015a.

HKEY_LOCAL_MACHINE\SOFTWARE\Classes
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes

To change permissions for registry, you need to run REGEDIT as administrator. (Or open a command window as administrator and type REGEDIT.)

Some .CHM files may not render properly on Windows Vista and Windows 7

Posted on Jan 1, 2015

From http://support.microsoft.com/kb/2021383

Symptoms
When attempting to open a Compiled HTML Help (.CHM) file on Windows Vista or Windows 7, the file may open but display one of the following messages instead of the expected content:

– Navigation to the webpage was canceled.
– Action canceled.

Cause
This will occur if the .CHM file has been flagged as downloaded from an untrusted source, such as the Internet.

Resolution
To resolve this issue, carry out the following steps:

– Right-click the .CHM file and choose Properties
– On the General tab, click the button labeled “Unblock”
– Click OK

[wxWidgets] Compiling wxWidgets for MS Windows

Posted on Dec 30, 2014

1. Get the latest source code from https://www.wxwidgets.org/downloads/ (ver 3.0.2 as of Dec 30, 2014) and unzip it somewhere.

2. Go to ./build/msw

3. Compile
– For MS Visual Studio, find a solution file for your VS version (e.g., wx_vc12.sln) and build.
– For MinGW, open a cmd window and set the bin folder of MinGW in the beginning of your PATH environment variable, like the following example.

set "PATH = C:\GNU\mingw64\bin;%path%"

Then, run the following commands, depending on the version you want to build.

@ release DLL
mkdir ..\..\lib\gcc_dll\mswu\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=1 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=1 UNICODE=1 MSLU=0

@ debug DLL
mkdir ..\..\lib\gcc_dll\mswud\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=1 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=1 UNICODE=1 MSLU=0

@ release static LIB
mkdir ..\..\lib\gcc_lib\mswu\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=0 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=0 UNICODE=1 MSLU=0

@ debug static LIB
mkdir ..\..\lib\gcc_lib\mswud\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=0 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=0 UNICODE=1 MSLU=0

Continue…