Skip to content

matlab generate the same random number everytime

June 16, 2017

use the following command before the rand function, you will get the same random number everytime you run the m file.

rand(‘seed’, 0);

rand

Set latex font

June 12, 2017

The command is:

\renewcommand*\rmdefault{ptm} %ppl

if you want to understand the three letter word: ptm or ppl. Read the table III of this document: http://tug.ctan.org/macros/latex/required/psnfss/psnfss2e.pdf

Here is a good introduction:

https://www.tug.org/pracjourn/2006-1/schmidt/schmidt.pdf

Abbrivation

March 16, 2017

Theorem -> Thm.
Corollary -> Cor.
See https://en.wikipedia.org/wiki/List_of_mathematical_abbreviations

Chapter -> Chap.

see https://en.wikipedia.org/wiki/List_of_legal_abbreviations

 

Insert Youtube video to powerpoint

February 28, 2017

Keywords: youtube, video, PPT, powerpoint, starting time

  • First, go to youtube and find the video. Then click Share->Embed. You will get a code as below:

link1

  • Second, paste the code to word and modify it. Specify the starting and ending times as shown below.

link2

  • Third, go to PPT and click Insert->Video->Online Video->From a Video Embed Code (not the Youtube one). Copy and paste and nail it.

 

 

Bearing Laplacian: Matlab code

February 27, 2017

Bearing Laplacian is important in the area of bearing rigidity. Here is the matlab code to generate the bearing Laplacian of a given network. If the rank of the bearing Laplacian is equal to d*n-d-1, then the network is bearing rigid.

keywords: bearing rigidity, bearing Laplacian

clc;clear;close all
% positions of the nodes in the network
p_all=[0 0 0;
   0 1 0;
   -1 0 0;
   0 0 1]';
d=size(p_all,1); % dimension
n=size(p_all,2); % number of nodes
% The symmetric adjacent matrix
neighborMat=zeros(n,n);
neighborMat(1,2)=1;neighborMat(1,4)=1;
neighborMat(2,3)=1;
neighborMat(3,4)=1;
neighborMat=neighborMat+neighborMat';

% Calculate the bearing Laplacian L
L=zeros(d*n,d*n);
for i=1:n
    for j=1:n
        if neighborMat(i,j)~=0 && i~=j
            pi=p_all(:,i);
            pj=p_all(:,j);
            gij=(pj-pi)/norm(pj-pi);
            Pgij=eye(d)-gij*gij';
            L(d*(i-1)+1:d*(i-1)+d,d*(j-1)+1:d*(j-1)+d)=-Pgij;
            L(d*(i-1)+1:d*(i-1)+d,d*(i-1)+1:d*(i-1)+d)...
             =L(d*(i-1)+1:d*(i-1)+d,d*(i-1)+1:d*(i-1)+d)+Pgij;
        end
    end
end

% See if the rank of L is equal to d*n-d-1. If so, the network is bearing rigid
rank(L)-(d*n-d-1)

A special but useful orthogonal projection matrix

February 18, 2017

untitled

untitled

untitled

 

See details in the memo

matlab annotation

November 28, 2016

x=[0.25,0.25];
y=[0.45,0.32];
a=annotation(‘textarrow’,x,y,’String’,’x_{2}(t), x_{14}(t)’);
set(a, ‘color’, myRed, ‘interpreter’, ‘tex’, ‘fontSize’, 15)