Category Archives: Tips

Matlab compiler installation. If you have trouble after installation of Microsoft Windows SDK 7.1

Solution for the Matlab compiler installation. If you have trouble after installation of Microsoft Windows SDK 7.1

Today I am writing a tip to solve a Matlab compiler setup problem. 

If you want to use MEX or any Matlab compiling technology, you need a compiler. Windows does not have a default compiler. So you have to install. If you don’t have any compiler, you would see the below message.

>> mex -setup

Welcome to mex -setup. This utility will help you set up 
a default compiler. For a list of supported compilers, see 
http://www.mathworks.com/support/compilers/R2013a/win64.html 

Please choose your compiler for building MEX-files: 

Would you like mex to locate installed compilers [y]/n? y

No supported SDK or compiler was found on this computer. 
For a list of supported compilers, see 
http://www.mathworks.com/support/compilers/R2013a/win64.html 

Error using mex (line 206)
Unable to complete successfully.

If you follow the link, you can install “Microsoft Windows SDK 7.1”

BUT, IMPORTANT, if you don’t have “.NET Framework 4.0,” you cannot install the compiler. As shown in the below figure, you MUST install .NET Framework 4.0 for installation of the windows compiler.

Matlab compiler problem, if you have trouble after the installation of Microsoft Windows SDK 7.1

Matlab compiler problem, if you have trouble after the installation of Microsoft Windows SDK 7.1

Then, I wish this post can help to solve your problem.

Thank you.

—————————————————————————————————————————–

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————————————–

C++ code for reading unknown size matrix from text file

C++ code for reading unknown size matrix from text file

In this post, I upload my program {C++ code for reading unknown size matrix from text file } <download> which imports an arbitrary size matrix (or 2D array) from text (txt) file. This is c++ code.

The below is an execution result. The first figure is a text file including a matrix, the next figure is an execution screen. It’s very easy to use.

xtxt

text file to import. It has an arbitrary size matrix

screen

execution screen image, it imported the matrix from the above text fileSometimes, we want to import a matrix that we don’t know its size, especially when the file was generated from other programs.

I had googled for long time, and I realized that it is not easy to find. So, I made.

You don’t need to indicate the size of matrix, (cols and rows). It automatically imports and outputs, double type vector,  column and row size. It is very easy to use, and you can download the source code from here  <download>.

The only thing you should do is just download the source code, and import “x.txt” or “y.txt” which includes an arbitrary matrix.

Enjoy my program { C++ code for reading unknown size matrix from text file } Then good luck.

I referred partially this site.

http://stackoverflow.com/questions/1321137/convert-string-containing-several-numbers-into-integers

—————————————————————————————————————————–

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————————————–

Very good source code for serial communication in QT Linux envirionment

< Source code for serial communication in QT Linux envirionment>

The below site has pretty good source code for serial communication in Linux QT environment.

You can download and learn how to use it.

http://www.embedded4fun.com/serial-port-interfacing-in-qt/

 

The below is how to install the code.  ( from the upper site)

  • cd <any folder (preferrably to the QtSDK installation folder)>
  • git clone https://code.google.com/p/qextserialport/
  • cd qextserialport
  • qmake
  • make
  • make install

<download>

Hyperterminal for serial communication (rs232 or rs485), download

Hyperterminal for serial communication (rs232 or rs485), download 

When I used Windows XP, I loved to use Hyperterminal because it is pretty simple and easy to use for serial communication. Especially it is pretty good for RS232 or RS485 communication. But now Windows does not support Hyperterminal any more.

So. I am attaching the previous program. You can download the program from the below link.

<Hyperterminal Download>

Numerical Jacobian matrix calculation method with matlab code

In this post, I share a numerical Jacobian matrix calculation method with matlab code.

Actually there is a function in Matlab inherently, but it is very complex. ( look at the function, NumJac ), So I made a very simple version. I wish this can help you.

You can download from here.

The attachment file includes 

1. NumJacob.m : main file it generates jacobian matrix. 

2. Demo.m : demo file

3. test_func.m : test function to show its demo

 

The below is a simple example.

>> NumJacob(@cos,1)

ans =

-0.8415

 

>> x0=[0;1]; other_param=[1;2];
>> df=NumJacob(@test_func,x0,other_param)

df =

1.0000 0
0 2.0000

 

 

Because the code is very easy, probably you can easily understand the codes.

Then, good luck ^^

if you have any question, please leave me a comment below.

 

Added on Feb 07. 2014

I am uploading another demo file to give a solution of Mahmudul’s request (for detail, see the comment).

This demo file is to get a numerical Jacobian for the below function

y1′ = y2*y3; y1(0) = 0
y2′ = -y1*y3; y2(0) = 1
y3′ = -0.51*y1*y3; y3(0) =1

Download this demo file. 

 

Added on Mar/21 2015

If you are interested in calculating numerical Jocobian matrix for a complex number, please read this post.

http://youngmok.com/matlab-code-for-numerical-calculation-of-jacobian-matrix-for-a-complex-number/

 

—————————————————————————————————

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————

 

 

 

Parallel computation with Matlab, SPMD. Explanation with simple example code

Today I’d like to introduce a parallel computation skill in Matlab.

I also heard that the use of parallel computation in Matlab is very easy. But it was better than my expectation. Wonderful!! Smile

You need to know the usage of SPMD. It is pretty easy.

First let’s the code, you can also download this file in the attachment, click <here>.
parallel_computation_spmd

 

The result is the below

Starting matlabpool using the ‘local’ configuration … connected to 4 labs.
Elapsed time is 120.482356 seconds.
Sending a stop signal to all the labs … stopped.
Elapsed time is 167.796932 seconds.

Because, I did many other works in the calculation time, Its result is not very fast, The slowest CPU core determined the final computation time. But its performance is really good if you have more than 4 multi cpu cores.

I wish this post can help your understanding about the use of SPMD in Matlab.

if you have any question, please leave me a comment below.

—————————————————————————————————

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————