Skip to content

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)

Matlab: plot multi-agent formation control

November 2, 2016

very easy to use!! just copy and paste to your m file and it works!!

Note: set up the input arguments

  • x_all_time
  • num
  • neighborMat
function fcn_myPlot(x_all_time)
global A d n
num=n;
neighborMat=A;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
graycolor=[0.5 0.5 0.5];
markersize=30;
textsize=25;
finalcolor=[0 0 1]*0.8;
%
figure;
hold on; box on; axis equal
% set label and tick
fontsize=20;
set(gca, 'fontSize', fontsize)
set(get(gca, 'xlabel'), 'String', 'x', 'fontSize', fontsize);
set(get(gca, 'ylabel'), 'String', 'y', 'fontSize', fontsize);
% hide label and tick
% set(gca, 'xtick', [])
% set(gca, 'ytick', [])
% boxcolor=0.7*ones(1,3);
% set(gca, 'xcolor', boxcolor)
% set(gca, 'ycolor', boxcolor)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot agent trajectory
for i=1:num
    xi_all=x_all_time.signals.values(:,2*i-1);
    yi_all=x_all_time.signals.values(:,2*i);
    plot(xi_all, yi_all, '--', 'color', graycolor);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% initial formation
% for i=1:num
%     for j=i+1:num
%         if neighborMat(i,j)==1
%             pi=x_all_time.signals.values(1,2*i-1:2*i)';
%             pj=x_all_time.signals.values(1,2*j-1:2*j)';
%             line([pi(1),pj(1)], [pi(2),pj(2)], 'linewidth', 2, 'color', graycolor);
%         end
%     end
% end
for i=1:num
    xi_init=x_all_time.signals.values(1,2*i-1);
    yi_init=x_all_time.signals.values(1,2*i);
    plot(xi_init, yi_init, 'o', 'MarkerEdgeColor', graycolor, 'MarkerFaceColor', graycolor, 'markersize', 10)
end
% plot circles and text: initial
for i=1:num
    xi_init=x_all_time.signals.values(1,2*i-1);
    yi_init=x_all_time.signals.values(1,2*i);
    plot(xi_init, yi_init, 'o', ...
        'MarkerSize', markersize,...
        'linewidth', 2,...
        'MarkerEdgeColor', graycolor,...
        'markerFaceColor', 'white');
    text(xi_init, yi_init, num2str(i),...
        'color', graycolor, 'FontSize', textsize, 'horizontalAlignment', 'center', 'FontName', 'times');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% final formation
for i=1:num
    for j=i+1:num
        if neighborMat(i,j)==1
            pi=x_all_time.signals.values(end,2*i-1:2*i)';
            pj=x_all_time.signals.values(end,2*j-1:2*j)';
            line([pi(1),pj(1)], [pi(2),pj(2)], 'linewidth', 2, 'color', finalcolor);
        end
    end
end
% plot circles and text: final
for i=1:num
    xi_init=x_all_time.signals.values(end,2*i-1);
    yi_init=x_all_time.signals.values(end,2*i);
    plot(xi_init, yi_init, 'o', ...
        'MarkerSize', markersize,...
        'linewidth', 2,...
        'MarkerEdgeColor', finalcolor,...
        'markerFaceColor', [1 1 1]);
    text(xi_init, yi_init, num2str(i),...
        'color', finalcolor, 'FontSize', textsize, 'horizontalAlignment', 'center', 'FontName', 'times');
end
% % intermediate formation
% for k=1:size(x_all_time.time,1)
%     for i=1:num
%         for j=i+1:num
%             if neighborMat(i,j)==1
%                 pi=x_all_time.signals.values(k,2*i-1:2*i)';
%                 pj=x_all_time.signals.values(k,2*j-1:2*j)';
%                 line([pi(1),pj(1)], [pi(2),pj(2)], 'linewidth', 1, 'color', rand(1,3));
%             end
%         end
%     end
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set limit
xlim=get(gca, 'xlim');
ylim=get(gca, 'ylim');
delta=0.2;
xlim=xlim+[-delta,delta];
ylim=ylim+[-delta,delta];
set(gca, 'xlim', xlim, 'ylim', ylim);


Windows 10 – keyboard problem: apostrophe, single quote do not show up

November 2, 2016

Probelm: when I press the key on the top-left corner to type apostrophe or wavy line, it does not show up until I press another key.

Reason: that is because I used US-international keyboard layout. See the following using link. However, the link below does not match my system very much because my win 10 is more up to date and some settings are different.

http://superuser.com/questions/122625/apostrophes-and-double-quotes-dont-show-up-until-i-type-the-next-letter

Solution: in my system, search Languarge->change your langurate preferences->Options->add an input method-> choose “US” (not the one in the link)

Remove the previous “US-international”. Now it works!!