我使用选项“保存”->“导出到 LaTex”导出了我的 matlab 代码(.mlx 格式的文件),并获得了两个文件,一个是 .tex 格式,另一个是 .sty 格式。我如何将这些文件添加到我的 overleaf 项目中?
你能解释一下我如何才能删除数字列以及如何才能改变文本的颜色吗?
文件 Q2_esercizi_1_2_3.tex 的内容:
% This LaTeX was auto-generated from MATLAB code.
% To make changes, update the MATLAB code and export to LaTeX again.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{color}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{epstopdf}
\usepackage[table]{xcolor}
\usepackage{matlab}
\sloppy
\epstopdfsetup{outdir=./}
\graphicspath{ {./Q2_esercizi_1_2_3_images/} }
\begin{document}
\matlabtitle{\textbf{DSV\_Quaderno 2: Orientamento del velivolo e trasformazione di assi}}
\matlabheading{Esercizio 2.1: Orientamento di un velivolo in assi terra}
\matlabheadingtwo{Load aircraft 3D model}
\begin{matlabcode}
clear all; close all; clc;
% see http://wpage.unina.it/agodemar/DSV-DQV/aircraft_models.zip
shapeScaleFactor = 1.0;
[V, F, C] = loadAircraftSTL('F-22_Raptor.stl', shapeScaleFactor);
\end{matlabcode}
\begin{matlaboutput}
Reading vertex num: 250.
Reading vertex num: 500.
Reading vertex num: 750.
Reading vertex num: 1000.
Reading vertex num: 1250.
Reading vertex num: 1500.
Reading vertex num: 1750.
Reading vertex num: 2000.
Reading vertex num: 2250.
Reading vertex num: 2500.
Reading vertex num: 2750.
Reading vertex num: 3000.
Reading vertex num: 3250.
Reading vertex num: 3500.
Reading vertex num: 3750.
Reading vertex num: 4000.
Reading vertex num: 4250.
Reading vertex num: 4500.
Reading vertex num: 4750.
Reading vertex num: 5000.
Reading vertex num: 5250.
Reading vertex num: 5500.
Reading vertex num: 5750.
Reading vertex num: 6000.
Reading vertex num: 6250.
Reading vertex num: 6500.
Reading vertex num: 6750.
Reading vertex num: 7000.
Reading vertex num: 7250.
Reading vertex num: 7500.
Reading vertex num: 7750.
Reading vertex num: 8000.
Reading vertex num: 8250.
Reading vertex num: 8500.
Reading vertex num: 8750.
Reading vertex num: 9000.
Reading vertex num: 9250.
Reading vertex num: 9500.
Reading vertex num: 9750.
Reading vertex num: 10000.
Reading vertex num: 10250.
Reading vertex num: 10500.
Reading vertex num: 10750.
Reading vertex num: 11000.
Reading vertex num: 11250.
Reading vertex num: 11500.
Reading vertex num: 11750.
Reading vertex num: 12000.
Reading vertex num: 12250.
Reading vertex num: 12500.
Reading vertex num: 12750.
Reading vertex num: 13000.
Reading vertex num: 13250.
Reading vertex num: 13500.
Reading vertex num: 13750.
Reading vertex num: 14000.
Reading vertex num: 14250.
Reading vertex num: 14500.
Reading vertex num: 14750.
Reading vertex num: 15000.
Reading vertex num: 15250.
Reading vertex num: 15500.
Reading vertex num: 15750.
Reading vertex num: 16000.
Reading vertex num: 16250.
Reading vertex num: 16500.
Reading vertex num: 16750.
Reading vertex num: 17000.
Reading vertex num: 17250.
Reading vertex num: 17500.
Reading vertex num: 17750.
Reading vertex num: 18000.
Reading vertex num: 18250.
Reading vertex num: 18500.
Reading vertex num: 18750.
Reading vertex num: 19000.
Reading vertex num: 19250.
Reading vertex num: 19500.
Reading vertex num: 19750.
Reading vertex num: 20000.
Reading vertex num: 20250.
Reading vertex num: 20500.
Reading vertex num: 20750.
Reading vertex num: 21000.
Reading vertex num: 21250.
Reading vertex num: 21500.
Reading vertex num: 21750.
Reading vertex num: 22000.
Reading vertex num: 22250.
Reading vertex num: 22500.
Reading vertex num: 22750.
Reading vertex num: 23000.
Reading vertex num: 23250.
Reading vertex num: 23500.
Reading vertex num: 23750.
Reading vertex num: 24000.
Reading vertex num: 24250.
Reading vertex num: 24500.
Reading vertex num: 24750.
Reading vertex num: 25000.
Reading vertex num: 25250.
Reading vertex num: 25500.
Reading vertex num: 25750.
Reading vertex num: 26000.
Reading vertex num: 26250.
Reading vertex num: 26500.
Reading vertex num: 26750.
Reading vertex num: 27000.
Reading vertex num: 27250.
Reading vertex num: 27500.
Reading vertex num: 27750.
Reading vertex num: 28000.
Reading vertex num: 28250.
Reading vertex num: 28500.
Reading vertex num: 28750.
Reading vertex num: 29000.
Reading vertex num: 29250.
Reading vertex num: 29500.
Reading vertex num: 29750.
Reading vertex num: 30000.
Reading vertex num: 30250.
Reading vertex num: 30500.
Reading vertex num: 30750.
Reading vertex num: 31000.
Reading vertex num: 31250.
Reading vertex num: 31500.
Reading vertex num: 31750.
Reading vertex num: 32000.
Reading vertex num: 32250.
Reading vertex num: 32500.
Reading vertex num: 32750.
Reading vertex num: 33000.
Reading vertex num: 33250.
Reading vertex num: 33500.
Reading vertex num: 33750.
Reading vertex num: 34000.
Reading vertex num: 34250.
Reading vertex num: 34500.
Reading vertex num: 34750.
Reading vertex num: 35000.
Reading vertex num: 35250.
Reading vertex num: 35500.
Reading vertex num: 35750.
Reading vertex num: 36000.
Reading vertex num: 36250.
Reading vertex num: 36500.
Reading vertex num: 36750.
Reading vertex num: 37000.
Reading vertex num: 37250.
Reading vertex num: 37500.
Reading vertex num: 37750.
Reading vertex num: 38000.
Reading vertex num: 38250.
Reading vertex num: 38500.
Reading vertex num: 38750.
Reading vertex num: 39000.
Reading vertex num: 39250.
Reading vertex num: 39500.
Reading vertex num: 39750.
Reading vertex num: 40000.
Reading vertex num: 40250.
Reading vertex num: 40500.
Reading vertex num: 40750.
Reading vertex num: 41000.
Reading vertex num: 41250.
Reading vertex num: 41500.
Reading vertex num: 41750.
Reading vertex num: 42000.
Reading vertex num: 42250.
Reading vertex num: 42500.
Reading vertex num: 42750.
Reading vertex num: 43000.
Reading vertex num: 43250.
Reading vertex num: 43500.
Reading vertex num: 43750.
Reading vertex num: 44000.
Reading vertex num: 44250.
Reading vertex num: 44500.
Reading vertex num: 44750.
Reading vertex num: 45000.
Reading vertex num: 45250.
Reading vertex num: 45500.
Reading vertex num: 45750.
Reading vertex num: 46000.
Reading vertex num: 46250.
Reading vertex num: 46500.
Reading vertex num: 46750.
Reading vertex num: 47000.
Reading vertex num: 47250.
Reading vertex num: 47500.
Reading vertex num: 47750.
Reading vertex num: 48000.
Reading vertex num: 48250.
Reading vertex num: 48500.
Reading vertex num: 48750.
Reading vertex num: 49000.
Reading vertex num: 49250.
Reading vertex num: 49500.
Reading vertex num: 49750.
Reading vertex num: 50000.
Reading vertex num: 50250.
Reading vertex num: 50500.
Reading vertex num: 50750.
Reading vertex num: 51000.
Reading vertex num: 51250.
Reading vertex num: 51500.
Reading vertex num: 51750.
Reading vertex num: 52000.
Reading vertex num: 52250.
Reading vertex num: 52500.
Reading vertex num: 52750.
Reading vertex num: 53000.
Reading vertex num: 53250.
Reading vertex num: 53500.
Reading vertex num: 53750.
Reading vertex num: 54000.
Reading vertex num: 54250.
Reading vertex num: 54500.
Reading vertex num: 54750.
Reading vertex num: 55000.
Reading vertex num: 55250.
Reading vertex num: 55500.
Reading vertex num: 55750.
Reading vertex num: 56000.
Reading vertex num: 56250.
Reading vertex num: 56500.
Reading vertex num: 56750.
Reading vertex num: 57000.
Reading vertex num: 57250.
Reading vertex num: 57500.
Reading vertex num: 57750.
Reading vertex num: 58000.
Reading vertex num: 58250.
Reading vertex num: 58500.
Reading vertex num: 58750.
Reading vertex num: 59000.
Reading vertex num: 59250.
Reading vertex num: 59500.
Reading vertex num: 59750.
Reading vertex num: 60000.
Reading vertex num: 60250.
Reading vertex num: 60500.
Reading vertex num: 60750.
Reading vertex num: 61000.
Reading vertex num: 61250.
Reading vertex num: 61500.
Reading vertex num: 61750.
Reading vertex num: 62000.
Reading vertex num: 62250.
Reading vertex num: 62500.
Reading vertex num: 62750.
Reading vertex num: 63000.
Reading vertex num: 63250.
Reading vertex num: 63500.
Reading vertex num: 63750.
Reading vertex num: 64000.
Reading vertex num: 64250.
Reading vertex num: 64500.
Reading vertex num: 64750.
Reading vertex num: 65000.
Reading vertex num: 65250.
Reading vertex num: 65500.
Reading vertex num: 65750.
Reading vertex num: 66000.
Reading vertex num: 66250.
Reading vertex num: 66500.
Reading vertex num: 66750.
Reading vertex num: 67000.
Reading vertex num: 67250.
Reading vertex num: 67500.
Reading vertex num: 67750.
Reading vertex num: 68000.
Reading vertex num: 68250.
Reading vertex num: 68500.
Reading vertex num: 68750.
Reading vertex num: 69000.
Reading vertex num: 69250.
Reading vertex num: 69500.
Reading vertex num: 69750.
Reading vertex num: 70000.
Reading vertex num: 70250.
Reading vertex num: 70500.
Reading vertex num: 70750.
Reading vertex num: 71000.
Reading vertex num: 71250.
Reading vertex num: 71500.
Reading vertex num: 71750.
Reading vertex num: 72000.
Reading vertex num: 72250.
Reading vertex num: 72500.
Reading vertex num: 72750.
Reading vertex num: 73000.
Reading vertex num: 73250.
Reading vertex num: 73500.
Reading vertex num: 73750.
Reading vertex num: 74000.
Reading vertex num: 74250.
Reading vertex num: 74500.
Reading vertex num: 74750.
Reading vertex num: 75000.
Reading vertex num: 75250.
Reading vertex num: 75500.
Reading vertex num: 75750.
Reading vertex num: 76000.
Reading vertex num: 76250.
Reading vertex num: 76500.
Reading vertex num: 76750.
Reading vertex num: 77000.
Reading vertex num: 77250.
Reading vertex num: 77500.
Reading vertex num: 77750.
Reading vertex num: 78000.
Reading vertex num: 78250.
Reading vertex num: 78500.
Reading vertex num: 78750.
Reading vertex num: 79000.
Reading vertex num: 79250.
Reading vertex num: 79500.
Reading vertex num: 79750.
Reading vertex num: 80000.
Reading vertex num: 80250.
Reading vertex num: 80500.
Reading vertex num: 80750.
Reading vertex num: 81000.
Reading vertex num: 81250.
Reading vertex num: 81500.
Reading vertex num: 81750.
Reading vertex num: 82000.
Reading vertex num: 82250.
Reading vertex num: 82500.
Reading vertex num: 82750.
Reading vertex num: 83000.
Reading vertex num: 83250.
Reading vertex num: 83500.
Reading vertex num: 83750.
Reading vertex num: 84000.
Reading vertex num: 84250.
Reading vertex num: 84500.
Reading vertex num: 84750.
Reading vertex num: 85000.
Reading vertex num: 85250.
Reading vertex num: 85500.
Reading vertex num: 85750.
Reading vertex num: 86000.
Reading vertex num: 86250.
Reading vertex num: 86500.
Reading vertex num: 86750.
Reading vertex num: 87000.
Reading vertex num: 87250.
Reading vertex num: 87500.
Reading vertex num: 87750.
Reading vertex num: 88000.
Reading vertex num: 88250.
Reading vertex num: 88500.
Reading vertex num: 88750.
Reading vertex num: 89000.
Reading vertex num: 89250.
Reading vertex num: 89500.
Reading vertex num: 89750.
Reading vertex num: 90000.
Reading vertex num: 90250.
Reading vertex num: 90500.
Reading vertex num: 90750.
Reading vertex num: 91000.
Reading vertex num: 91250.
Reading vertex num: 91500.
Reading vertex num: 91750.
Reading vertex num: 92000.
Reading vertex num: 92250.
Reading vertex num: 92500.
Reading vertex num: 92750.
Reading vertex num: 93000.
Reading vertex num: 93250.
Reading vertex num: 93500.
Reading vertex num: 93750.
Reading vertex num: 94000.
Reading vertex num: 94250.
Reading vertex num: 94500.
Reading vertex num: 94750.
Reading vertex num: 95000.
Reading vertex num: 95250.
Reading vertex num: 95500.
Reading vertex num: 95750.
Reading vertex num: 96000.
Reading vertex num: 96250.
Reading vertex num: 96500.
Reading vertex num: 96750.
Reading vertex num: 97000.
Reading vertex num: 97250.
Reading vertex num: 97500.
Reading vertex num: 97750.
Reading vertex num: 98000.
Reading vertex num: 98250.
Reading vertex num: 98500.
Reading vertex num: 98750.
Reading vertex num: 99000.
Reading vertex num: 99250.
Reading vertex num: 99500.
Reading vertex num: 99750.
Reading vertex num: 100000.
Reading vertex num: 100250.
Reading vertex num: 100500.
Reading vertex num: 100750.
Reading vertex num: 101000.
Reading vertex num: 101250.
Reading vertex num: 101500.
Reading vertex num: 101750.
Reading vertex num: 102000.
Reading vertex num: 102250.
Reading vertex num: 102500.
Reading vertex num: 102750.
Reading vertex num: 103000.
Reading vertex num: 103250.
Reading vertex num: 103500.
Reading vertex num: 103750.
Reading vertex num: 104000.
Reading vertex num: 104250.
Reading vertex num: 104500.
Reading vertex num: 104750.
Reading vertex num: 105000.
Reading vertex num: 105250.
Reading vertex num: 105500.
Reading vertex num: 105750.
Reading vertex num: 106000.
Reading vertex num: 106250.
Reading vertex num: 106500.
Reading vertex num: 106750.
Reading vertex num: 107000.
Reading vertex num: 107250.
Reading vertex num: 107500.
Reading vertex num: 107750.
Reading vertex num: 108000.
Reading vertex num: 108250.
Reading vertex num: 108500.
Reading vertex num: 108750.
Reading vertex num: 109000.
Reading vertex num: 109250.
Reading vertex num: 109500.
Reading vertex num: 109750.
Reading vertex num: 110000.
Reading vertex num: 110250.
Reading vertex num: 110500.
Reading vertex num: 110750.
Reading vertex num: 111000.
Reading vertex num: 111250.
Reading vertex num: 111500.
Reading vertex num: 111750.
Reading vertex num: 112000.
Reading vertex num: 112250.
Reading vertex num: 112500.
Reading vertex num: 112750.
Reading vertex num: 113000.
Reading vertex num: 113250.
Reading vertex num: 113500.
Reading vertex num: 113750.
Reading vertex num: 114000.
Reading vertex num: 114250.
Reading vertex num: 114500.
Reading vertex num: 114750.
Reading vertex num: 115000.
Reading vertex num: 115250.
Reading vertex num: 115500.
Reading vertex num: 115750.
Reading vertex num: 116000.
Reading vertex num: 116250.
Reading vertex num: 116500.
Reading vertex num: 116750.
Reading vertex num: 117000.
Reading vertex num: 117250.
Reading vertex num: 117500.
Reading vertex num: 117750.
Reading vertex num: 118000.
Reading vertex num: 118250.
Reading vertex num: 118500.
Reading vertex num: 118750.
Reading vertex num: 119000.
Reading vertex num: 119250.
Reading vertex num: 119500.
Reading vertex num: 119750.
Reading vertex num: 120000.
Reading vertex num: 120250.
Reading vertex num: 120500.
Reading vertex num: 120750.
Reading vertex num: 121000.
Reading vertex num: 121250.
Reading vertex num: 121500.
Reading vertex num: 121750.
Reading vertex num: 122000.
Reading vertex num: 122250.
Reading vertex num: 122500.
Reading vertex num: 122750.
Reading vertex num: 123000.
Reading vertex num: 123250.
Reading vertex num: 123500.
Reading vertex num: 123750.
Reading vertex num: 124000.
Reading vertex num: 124250.
Reading vertex num: 124500.
Reading vertex num: 124750.
Reading vertex num: 125000.
Reading vertex num: 125250.
Reading vertex num: 125500.
Reading vertex num: 125750.
Reading vertex num: 126000.
Reading vertex num: 126250.
Reading vertex num: 126500.
Reading vertex num: 126750.
Reading vertex num: 127000.
Reading vertex num: 127250.
Reading vertex num: 127500.
Reading vertex num: 127750.
Reading vertex num: 128000.
Reading vertex num: 128250.
Reading vertex num: 128500.
Reading vertex num: 128750.
Reading vertex num: 129000.
Reading vertex num: 129250.
Reading vertex num: 129500.
Reading vertex num: 129750.
Reading vertex num: 130000.
Reading vertex num: 130250.
Reading vertex num: 130500.
Reading vertex num: 130750.
Reading vertex num: 131000.
Reading vertex num: 131250.
Reading vertex num: 131500.
Reading vertex num: 131750.
Reading vertex num: 132000.
Reading vertex num: 132250.
Reading vertex num: 132500.
Reading vertex num: 132750.
Reading vertex num: 133000.
Reading vertex num: 133250.
Reading vertex num: 133500.
Reading vertex num: 133750.
Reading vertex num: 134000.
Reading vertex num: 134250.
Reading vertex num: 134500.
Reading vertex num: 134750.
Reading vertex num: 135000.
Reading vertex num: 135250.
Reading vertex num: 135500.
Reading vertex num: 135750.
Reading vertex num: 136000.
Reading vertex num: 136250.
Reading vertex num: 136500.
Reading vertex num: 136750.
Reading vertex num: 137000.
Reading vertex num: 137250.
Reading vertex num: 137500.
Reading vertex num: 137750.
Reading vertex num: 138000.
Reading vertex num: 138250.
Reading vertex num: 138500.
Reading vertex num: 138750.
Reading vertex num: 139000.
Reading vertex num: 139250.
Reading vertex num: 139500.
Reading vertex num: 139750.
Reading vertex num: 140000.
Reading vertex num: 140250.
Reading vertex num: 140500.
Reading vertex num: 140750.
Reading vertex num: 141000.
Reading vertex num: 141250.
Reading vertex num: 141500.
Reading vertex num: 141750.
Reading vertex num: 142000.
Reading vertex num: 142250.
Reading vertex num: 142500.
Reading vertex num: 142750.
Reading vertex num: 143000.
Reading vertex num: 143250.
Reading vertex num: 143500.
Reading vertex num: 143750.
Reading vertex num: 144000.
Reading vertex num: 144250.
Reading vertex num: 144500.
Reading vertex num: 144750.
Reading vertex num: 145000.
Reading vertex num: 145250.
Reading vertex num: 145500.
Reading vertex num: 145750.
Reading vertex num: 146000.
Reading vertex num: 146250.
Reading vertex num: 146500.
Reading vertex num: 146750.
Reading vertex num: 147000.
Reading vertex num: 147250.
Reading vertex num: 147500.
Reading vertex num: 147750.
Reading vertex num: 148000.
Reading vertex num: 148250.
Reading vertex num: 148500.
Reading vertex num: 148750.
Reading vertex num: 149000.
Reading vertex num: 149250.
Reading vertex num: 149500.
Reading vertex num: 149750.
Reading vertex num: 150000.
Reading vertex num: 150250.
Reading vertex num: 150500.
Reading vertex num: 150750.
Reading vertex num: 151000.
Reading vertex num: 151250.
Reading vertex num: 151500.
Reading vertex num: 151750.
Reading vertex num: 152000.
Reading vertex num: 152250.
Reading vertex num: 152500.
Reading vertex num: 152750.
Reading vertex num: 153000.
Reading vertex num: 153250.
Reading vertex num: 153500.
Reading vertex num: 153750.
Reading vertex num: 154000.
Reading vertex num: 154250.
Reading vertex num: 154500.
Reading vertex num: 154750.
Reading vertex num: 155000.
Reading vertex num: 155250.
Reading vertex num: 155500.
Reading vertex num: 155750.
Reading vertex num: 156000.
Reading vertex num: 156250.
Reading vertex num: 156500.
Reading vertex num: 156750.
Reading vertex num: 157000.
Reading vertex num: 157250.
Reading vertex num: 157500.
Reading vertex num: 157750.
Reading vertex num: 158000.
Reading vertex num: 158250.
Reading vertex num: 158500.
Reading vertex num: 158750.
Reading vertex num: 159000.
Reading vertex num: 159250.
Reading vertex num: 159500.
Reading vertex num: 159750.
Reading vertex num: 160000.
Reading vertex num: 160250.
Reading vertex num: 160500.
Reading vertex num: 160750.
Reading vertex num: 161000.
Reading vertex num: 161250.
Reading vertex num: 161500.
Reading vertex num: 161750.
Reading vertex num: 162000.
Reading vertex num: 162250.
Reading vertex num: 162500.
Reading vertex num: 162750.
Reading vertex num: 163000.
Reading vertex num: 163250.
\end{matlaboutput}
\begin{matlabcode}
%save shape in .mat format for future use
shape.V = V; shape.F = F; shape.C = C;
save('F-22_Raptor.mat', 'shape');
\end{matlabcode}
\matlabheadingtwo{Setup the figure/scene}
\begin{matlabcode}
h_fig1 = figure(1);
grid on
hold on
light('Position',[0.5 0.5 -1],'Style','local'); %original light position [1 0 -2]
% Trick to have Ze pointing downward and correct visualization
set(gca,'XDir','reverse');
set(gca,'ZDir','reverse');
%% Display aircraft shape
p = patch('faces', shape.F, 'vertices', shape.V);
set(p, 'facec', [0.20 0.73 1.00]); %light blue [0.20 0.73 1.00]rgb()
set(p, 'EdgeColor','none');
theView = [-114 14];
view(theView);
axis equal;
%axis([-1 1 -1 1 -1 1]);
%box on;
hold on;
\end{matlabcode}
\begin{center}
\includegraphics[width=\maxwidth{56.196688409433015em}]{figure_0.png}
\end{center}
\begin{matlabcode}
\end{matlabcode}
\matlabheadingtwo{Plot axes}
\begin{matlabcode}
xMax = 1.8*max(abs(shape.V(:,1)));
yMax = 1.8*max(abs(shape.V(:,2)));
zMax = 0.5*xMax;
quiver3(0,0,0,xMax,0,0, 'r','linewidth',2.5);
hold on
quiver3(0,0,0,0,yMax,0, 'g','linewidth',2.5);
hold on
quiver3(0,0,0,0,0,zMax, 'b','linewidth',2.5);
print('-depsc2','-r600',strcat('velivolo_BRF','.eps'));
\end{matlabcode}
\begin{center}
\includegraphics[width=\maxwidth{56.196688409433015em}]{figure_1.png}
\end{center}
\begin{matlabcode}
\end{matlabcode}
\matlabheadingtwo{OTTIMIZZAZIONE CODICE PRECEDENTE}
\begin{matlabcode}
%% Setup the figure/scene
h_fig2 = figure(2);
light('Position',[2 2 -5],'Style','local');
% Trick to have Ze pointing downward and correct visualization
set(gca,'XDir','reverse'); set(gca,'ZDir','reverse');
grid on; hold on; box on;
%% Load aircraft shape
shapeScaleFactor_bis = 1.0;
shape = loadAircraftMAT('F-22_Raptor.mat', shapeScaleFactor_bis);
%% Set the aircraft in place
% Posision in Earth axes
vXYZe = [2,2,-2];
% psi, theta, phi -> 'ZYX'
vEulerAngles = convang([20+90,-10,0],'deg','rad');
% Observer point-of-view
theView = [112 10];
% body axes settings
bodyAxesOptions.show = true;
bodyAxesOptions.magX = 2.0*shapeScaleFactor_bis;
bodyAxesOptions.magY = 2.0*shapeScaleFactor_bis;
bodyAxesOptions.magZ = 1.5*shapeScaleFactor_bis;
bodyAxesOptions.lineWidth = 2.5;
plotBodyE(h_fig2, shape, ...
vXYZe, vEulerAngles, ...
bodyAxesOptions, theView);
%Trick to change aircraft color
h = findobj(gca,'Type','Patch');
h.FaceColor = [0.1 0.7 1];
% Plot Earth axes
hold on;
xMax = max([abs(vXYZe(1)),5]);
yMax = max([abs(vXYZe(2)),5]);
zMax = 0.3*xMax; % max([abs(max(vXYZe(1))),0.18*xMax]);
vXYZ0 = [0,0,0];
vExtent = [xMax,yMax,zMax];
plotEarthAxes(h_fig2, vXYZ0, vExtent);
% draw CoG coordinate helper lines
hold on;
options.lineColor = 'k';
options.lineWidth = 1.5;
options.lineStyle = ':';
plotPoint3DHelperLines(h_fig2, vXYZe,options);
ylim([0 4]);
print('-depsc2','-r600',strcat('CoG_projection','.eps'));
\end{matlabcode}
\begin{center}
\includegraphics[width=\maxwidth{56.196688409433015em}]{figure_2.png}
\end{center}
\begin{matlabcode}
\end{matlabcode}
\matlabheading{Esercizio 2.2: Componenti della forza peso in assi velivolo}
\begin{matlabcode}
%% Mass data of Lockheed Martin-Boeing F-22 Raptor
mass = 29410; % kg
g = 9.81; % m/s^2
%% Euler angles
psi = vEulerAngles(1); theta = vEulerAngles(2); phi = vEulerAngles(3);
%% DCM
% Transf. matrix from Earth- to body-axes
Tbe = angle2dcm(psi, theta, phi, 'ZYX');
vWeight_E = [0; 0; mass*g] % N Ë
\end{matlabcode}
\begin{matlaboutput}
vWeight_E = 3x1
1.0e+05 *
0
0
2.8851
\end{matlaboutput}
\begin{matlabcode}
vWeight_B = Tbe*vWeight_E
\end{matlabcode}
\begin{matlaboutput}
vWeight_B = 3x1
1.0e+05 *
0.5010
0
2.8413
\end{matlaboutput}
\begin{matlabcode}
\end{matlabcode}
\matlabheading{Esercizio 2.3: Rappresentazione delle componenti del peso}
\begin{matlabcode}
%% Draw Weight pointing downward
hold on
scale_weight = 0.000005;
weightVecMag = scale_weight*mass*g;
quiver3( ...
vXYZe(1),vXYZe(2),vXYZe(3), ...
0, 0, weightVecMag, ...
'AutoScale', 'off', 'Color', [0 0 0], 'LineWidth', 2.5 ...
);
%% Vector W_XB * i_B
% application point along z_B
Teb=Tbe';
pWZB_B = scale_weight.*[0;0;vWeight_B(3)];
pWZB_E = vXYZe' + Teb*pWZB_B;
% Vector W_XB * i_B (body-components)
vWeight_XB_B = scale_weight.*[vWeight_B(1);0;0];
% Vector W_XB * i_B (Earth-components)
vWeight_XB_E = Teb*vWeight_XB_B;
quiver3( ...
pWZB_E(1), pWZB_E(2), pWZB_E(3), ...
vWeight_XB_E(1), vWeight_XB_E(2), vWeight_XB_E(3), ...
'AutoScale', 'off', 'Color', [0 0 0], 'LineWidth', 2.0, ...
'MaxHeadSize', 4.0 ...
);
print('-depsc2','-r600',strcat('componenti_peso','.eps'));
\end{matlabcode}
\begin{center}
\includegraphics[width=\maxwidth{56.196688409433015em}]{figure_3.png}
\end{center}
\end{document}
文件matlab.sty的内容:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{matlab}
\RequirePackage{verbatim}
\RequirePackage{fancyvrb}
\RequirePackage{alltt}
\RequirePackage{upquote}
\RequirePackage[framemethod=tikz]{mdframed}
\RequirePackage{hyperref}
\RequirePackage{color}
\newcommand{\maxwidth}[1]{\ifdim\linewidth>#1 #1\else\linewidth\fi}
\newcommand{\mlcell}[1]{{\color{output}\verbatim@font#1}}
\definecolor{output}{gray}{0.4}
% Unicode character conversions
\DeclareUnicodeCharacter{B0}{\ensuremath{^\circ}}
\DeclareUnicodeCharacter{21B5}{\ensuremath{\hookleftarrow}}
% Paragraph indentation
\setlength{\parindent}{0pt}
% Hyperlink style
\hypersetup{
colorlinks=true,
linkcolor=blue,
urlcolor=blue
}
% environment styles for MATLAB code and output
\mdfdefinestyle{matlabcode}{%
outerlinewidth=.5pt,
linecolor=gray!20!white,
roundcorner=2pt,
innertopmargin=.5\baselineskip,
innerbottommargin=.5\baselineskip,
innerleftmargin=1em,
backgroundcolor=gray!10!white
}
\newenvironment{matlabcode}{\verbatim}{\endverbatim}
\surroundwithmdframed[style=matlabcode]{matlabcode}
\newenvironment{matlaboutput}{%
\Verbatim[xleftmargin=1.25em, formatcom=\color{output}]%
}{\endVerbatim}
\newenvironment{matlabsymbolicoutput}{%
\list{}{\leftmargin=1.25em\relax}%
\item\relax%
\color{output}\verbatim@font%
}{\endlist}
\newenvironment{matlabtableoutput}[1]{%
{\color{output}%
\hspace*{1.25em}#1}%
}{}
% Table of Contents style
\newcounter{multititle}
\newcommand{\matlabmultipletitles}{\setcounter{multititle}{1}}
\newcounter{hastoc}
\newcommand{\matlabhastoc}{\setcounter{hastoc}{1}}
\newcommand{\matlabtitle}[1]{
\ifnum\value{multititle}>0
\ifnum\value{hastoc}>0
\addcontentsline{toc}{section}{#1}
\fi
\fi
\section*{#1}
}
\newcommand{\matlabheading}[1]{
\ifnum\value{hastoc}>0
\addcontentsline{toc}{subsection}{#1}
\fi
\subsection*{#1}
}
\newcommand{\matlabheadingtwo}[1]{
\ifnum\value{hastoc}>0
\addcontentsline{toc}{subsubsection}{#1}
\fi
\subsubsection*{#1}
}
\newcommand{\matlabheadingthree}[1]{
\ifnum\value{hastoc}>0
\addcontentsline{toc}{paragraph}{#1}
\fi
\paragraph*{#1}
}
\newcommand{\matlabtableofcontents}[1]{
\renewcommand{\contentsname}{#1}
\tableofcontents
}
答案1
您从 Matlab 导出的文件本身就是 LaTeX 文档,包括其自己的 .sty 文件(即包文件)、标题和格式。因此,您不能简单地使用\include
这些文件添加到您的文档中。
如果您想按原样包含整个文件,您可以编译从 Matlab 导出的文件,然后使用包pdfpages
和将生成的 PDF 文件(或其中的页面)包含到您自己的文档中\includepdf[pages=-]{compiled-matlab-file.pdf}
。这样,原始文件的所有格式都将保留。
如果您只想包含 Matlab 文件的部分内容,最简单的方法就是复制代码的部分内容并将其粘贴到您的文档中。从 Matlab 导出的文件使用matlab
在 .sty 文件中定义的自定义环境。但您可以轻松地从 .sty 文件中获取定义并将其放入您的序言中:
\usepackage{fancyvrb}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{matlabcode}{%
outerlinewidth=.5pt,
linecolor=gray!20!white,
roundcorner=2pt,
innertopmargin=.5\baselineskip,
innerbottommargin=.5\baselineskip,
innerleftmargin=1em,
backgroundcolor=gray!10!white
}
\newenvironment{matlabcode}{\Verbatim}{\endVerbatim}
\surroundwithmdframed[style=matlabcode]{matlabcode}
\definecolor{output}{gray}{0.4}
\newenvironment{matlaboutput}{%
\Verbatim[xleftmargin=1.25em, formatcom=\color{output}]%
}{\endVerbatim}
通过这个,你可以从你用 Matlab 导出的文件中复制matlabcode
和matlaboutput
块。如果你想将图像放入文档中,你可以像将它们包含在你从 Matlab 导出的文件中一样包含它们(你需要graphicx
在序言中加载包,当然,还要调整文件的路径):
\begin{center}
\includegraphics[width=\textwidth]{path-to-directory/figure_3.png}
\end{center}