51 lines
1.7 KiB
Matlab
51 lines
1.7 KiB
Matlab
|
function plot_move(yOut,time,path,bParam)
|
||
|
lengthCorRobot = length(bParam.corRobot);
|
||
|
robStateLen = size(bParam.model.origin.A,1);
|
||
|
lengthNode = length(bParam.edgeL);
|
||
|
tspan = bParam.tspan;
|
||
|
|
||
|
xi = 1:robStateLen:lengthCorRobot-1;
|
||
|
yi = 2:robStateLen:lengthCorRobot;
|
||
|
str_tmp = "@(e) plot(";
|
||
|
for i = 1:lengthNode-1
|
||
|
str_tmp = strcat(str_tmp,sprintf("yOut(%i,1:e),yOut(%i,1:e),",xi(i),yi(i)));
|
||
|
endfor
|
||
|
str_tmp = strcat(str_tmp,sprintf("yOut(%i,1:e),yOut(%i,1:e));",xi(i+1),yi(i+1)));
|
||
|
_plot_move = eval(str_tmp); %_plot_move(end);
|
||
|
|
||
|
|
||
|
% membuat fungsi plot robot di waktu
|
||
|
% tertentu
|
||
|
str_tmp = "@(t) plot( [";
|
||
|
for i = 1:robStateLen:lengthCorRobot
|
||
|
str_tmp = strcat( str_tmp, sprintf("yOut(%i,t), ",i));
|
||
|
endfor
|
||
|
str_tmp = strcat( str_tmp, sprintf("], ["));
|
||
|
for i = 2:robStateLen:lengthCorRobot
|
||
|
str_tmp = strcat( str_tmp, sprintf("yOut(%i,t), ",i));
|
||
|
endfor
|
||
|
str_tmp = strcat( str_tmp, sprintf("], \"^\");"));
|
||
|
plot_rb = eval(str_tmp); % plot_rb(coordinat)
|
||
|
|
||
|
str_tmp = "legend(";
|
||
|
for i = 1:numNodes(edgeL2adjL(bParam.edgeL))-1;
|
||
|
str_tmp =strcat(str_tmp,sprintf("\"R%i \", ",i));
|
||
|
endfor
|
||
|
str_tmp =strcat(str_tmp,sprintf("\"R%i \" )",++i));
|
||
|
|
||
|
|
||
|
for t=1:time
|
||
|
f=figure('visible', 'off');
|
||
|
hold on
|
||
|
_plot_move(t);
|
||
|
plot_rb(t);
|
||
|
eval(str_tmp);
|
||
|
filename=strcat(path,sprintf('x%03d%03d_y%03d%03d_kp1%03d_kp2%03d_%05d.png', ...
|
||
|
bParam.corRobot(4),bParam.corRobot(5),bParam.corRobot(7),bParam.corRobot(8),...
|
||
|
bParam.kp1,bParam.kp2,t));
|
||
|
print(filename);
|
||
|
hold off
|
||
|
close(f);
|
||
|
endfor
|
||
|
endfunction
|