440 likes | 583 Views
Radial basis function approximation. K-mean Algorithm. function y=my_kmeans(X,M) mx =mean(X); Y=rand(M,2)*0.1-0.05+mx; change =1; wh ile change < 10.^-6 D = cross_distances(X,Y) [xx ind]=min(D'); for i=1:K ind2=find(ind == i); Y_new(i,:) = mean( X( ind2,:));
E N D
Radial basis function approximation 軟體實作與計算實驗
K-mean Algorithm • function y=my_kmeans(X,M) • mx=mean(X); • Y=rand(M,2)*0.1-0.05+mx; • change =1; • while change < 10.^-6 • D = cross_distances(X,Y) • [xx ind]=min(D'); • for i=1:K • ind2=find(ind == i); • Y_new(i,:) = mean(X( ind2,:)); • end • change = mean(mean(Y-Y_new)); • end • return 軟體實作與計算實驗
Cross_Distance function D=cross_distance(X,Y) M=size(Y,1);N=size(X,1); A=sum(X.^2,2)*ones(1,M); C=ones(N,1)*sum(Y.^2,2)'; B=X*Y'; D=sqrt(A-2*B+C); 軟體實作與計算實驗
Radial basis function 軟體實作與計算實驗
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=157&objectType=Filehttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=157&objectType=File 軟體實作與計算實驗
Forward Kinematics 軟體實作與計算實驗
Frame positions x position of frame '2' y position of frame '2' 軟體實作與計算實驗
Position of frame 3 軟體實作與計算實驗
Position of tool x position of frame 'tool' y position of frame 'tool' 軟體實作與計算實驗
http://www.learnaboutrobots.com/forwardKinematics.htm 軟體實作與計算實驗
Forward Kinematics Problem statement • A schematic of a simple robot lying in the X-Y plane • Robot length • Three links of the robot • Given the ang joints, where is the robot's hand? • ? 軟體實作與計算實驗
Forward Kinematics for planar robot 軟體實作與計算實驗
Inverse kinematics At the position level, the problem is stated as, "Given the desired position of the robot's hand, what must be the angles at all of the robots joints? " 軟體實作與計算實驗
Y xt P x One link • Given Xt what is the joint angle P 軟體實作與計算實驗
Y xt P x 軟體實作與計算實驗
multiple solutions 軟體實作與計算實驗
Two links (xt yt) Y P2 P1 x 軟體實作與計算實驗
(xt yt) Y P2 P1 x 軟體實作與計算實驗
(xt yt) Y P2 P1 x 軟體實作與計算實驗
(xt yt) Y P2 P1 x 軟體實作與計算實驗
Forward kinematics of two-link robot 軟體實作與計算實驗
Inverse kinematics of two-link robot 軟體實作與計算實驗
Exercise • Write matlab functions to implement forward and inverse kinematics of a two-link robot 軟體實作與計算實驗
Example l1=1;l2=1; p1=pi/3;p2=pi/5; [x,y]=fkin(p1,p2,l1,l2) [p1,p2]=inverse_kin(x,y,l1,l2); p1/pi p2/pi 軟體實作與計算實驗
Nonlinear system 軟體實作與計算實驗
A set of nonlinear functions 軟體實作與計算實驗
x=linspace(-2,2); plot(x,x); hold on; plot(x,sqrt(4-x.^2)) plot(x,-sqrt(4-x.^2)) 軟體實作與計算實驗
function F = myfun(x) F(1) = x(1).^2 + x(2)^2-4; F(2) = x(1) - x(2); return 軟體實作與計算實驗
Least square of nonlinear functions 軟體實作與計算實驗
Demo_lsq function demo_lsq() x0= ones(1,2)*2; x = lsqnonlin(@myfun,x0) y=myfun(x); sum(y.^2) return function F = myfun(x) F(1) = x(1).^2 + x(2)^2 -4; F(2) = x(1) - x(2); return 軟體實作與計算實驗
x=linspace(-5,5); plot(x,sqrt(24-2*x.^2),'r');hold on; plot(x,-sqrt(24-2*x.^2),'r') plot(x,sqrt(12+x.^2),'b') plot(x,-sqrt(12+x.^2),'b') 軟體實作與計算實驗
Demo_lsq_2c source code 軟體實作與計算實驗
Nonlinear systems 軟體實作與計算實驗
Exercise Write a malab function to solve the following nonlinear system 軟體實作與計算實驗
PUMA Robot Matlab/Servo To Go software MATLAB Central File Exchange - 3D Puma Robot Demo puma3d.m gen_path.m 軟體實作與計算實驗