matlab生成pdf报告,MATLAB发布代码---生成文档pdf
1、前記:
發布?MATLAB??代碼文件 (.m) 可創建包括您的代碼、注釋和輸出的格式化文檔。發布代碼的常見原因是與其他人共享文檔以用于教學或演示,或者生成您代碼的可讀外部文檔。要在 MATLAB 編輯器中創建同時包含您的代碼、格式化內容和輸出的交互式文檔,請參閱在實時編輯器中創建實時腳本。
2、步驟----打開要發布的代碼文件(m文件)-----點擊發布----選擇編輯發布選項。如下:
點擊輸出文件,選擇格式和修改地址,點擊發布
如:源代碼為?Robotics System Toolbox中的機器人運動 (3)中的例子
%% Waypoint tracking demonstration using Robotics System Toolbox
% This demonstration performs inverse kinematics of a
% robot manipulator to follow a desired set of waypoints.
% Copyright 2017-2018 The MathWorks, Inc.
%% Load and display robot
clear
clc
robot = importrobot('irb_140.urdf');
axis([-0.6 0.8 -0.6 0.65 0 1.2]);
show(robot);
axes.CameraPositionMode = 'auto';
%% Create a set of desired wayPoints
wayPoints = [0.5 0.1 0.6;0.5 0.4 0.5]; % Alternate set of wayPoints
%wayPoints = [0.2 -0.2 0.02;0.15 0 0.28;0.15 0.05 0.2; 0.15 0.09 0.15;0.1 0.12 0.1; 0.04 0.1 0.2;0.25 0 0.15; 0.2 0.2 0.02];
exampleHelperPlotWaypoints(wayPoints);
%% Create a smooth curve from the waypoints to serve as trajectory
trajectory = cscvn(wayPoints');%在點之間創建軌跡
% Plot trajectory spline and waypoints
hold on
fnplt(trajectory,'r',2);
%% Perform Inverse Kinematics for a point in space
% Add end effector frame, offset from the grip link frame
eeOffset = 0.01;
eeBody = robotics.RigidBody('end_effector');
setFixedTransform(eeBody.Joint,trvec2tform([eeOffset 0 0]));
addBody(robot,eeBody,'link_6');
ik = robotics.InverseKinematics('RigidBodyTree',robot);
weights = [0.1 0.1 0 1 1 1];
initialguess = robot.homeConfiguration;
% Calculate the inverse kinematic solution using the "ik" solver
% Use desired weights for solution (First three are orientation, last three are translation)
% Since it is a 4-DOF robot with only one revolute joint in Z we do not
% put a weight on Z rotation; otherwise it limits the solution space
numTotalPoints =40;
% Evaluate trajectory to create a vector of end-effector positions
eePositions = ppval(trajectory,linspace(0,trajectory.breaks(end),numTotalPoints));
% Call inverse kinematics solver for every end-effector position using the
% previous configuration as initial guess
for idx = 1:size(eePositions,2)
tform = trvec2tform(eePositions(:,idx)');
configSoln(idx,:) = ik('end_effector',tform,weights,initialguess);
initialguess = configSoln(idx,:);
end
%% Visualize robot configurations
title('Robot waypoint tracking visualization')
hold on
axis([-0.6 0.8 -0.6 0.65 0 1.3]);
for idx = 1:size(eePositions,2)
show(robot,configSoln(idx,:), 'PreservePlot', false,'Frames','off');
pause(0.1)
end
%% Plot joints values
A = cat(1,configSoln.JointPosition);
clf
figure
stem(A)%overview
%% Joints
joint1=A(1:40,1);
joint2=A(41:80,1);
joint3=A(81:120,1);
joint4=A(121:160,1);
joint5=A(161:200,1);
joint6=A(201:240,1);
figure
stem(joint1,'LineStyle','none','MarkerFaceColor','r','MarkerEdgeColor','g')
title('Joint關節的值變化')
hold on
stem(joint2,'LineStyle','none','MarkerFaceColor','g','MarkerEdgeColor','b')
stem(joint3,'LineStyle','none','MarkerFaceColor','b','MarkerEdgeColor','y')
stem(joint4,'LineStyle','none','MarkerFaceColor','y','MarkerEdgeColor','m')
stem(joint5,'LineStyle','none','MarkerFaceColor','c','MarkerEdgeColor','w')
stem(joint6,'LineStyle','none','MarkerFaceColor','m','MarkerEdgeColor','b')
發布后生成的PDF文檔效果為:
3、后記:figure圖框的利用---打印圖窗、點擊箭頭修改圖占框大小、插入圖例修改data標簽,以便給論文提取所需的圖。
----------己亥年二月初六晚
總結
以上是生活随笔為你收集整理的matlab生成pdf报告,MATLAB发布代码---生成文档pdf的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言中extern修饰符的用法
- 下一篇: matlab人脸追踪,求大神帮助我这个菜