Hi again!
Thanks for the reply. For the moment, I must to do other things, so I will think about how to do the arctangent later...
I have two doubts. At first, I attach here my code:
Code: Select all
\documentclass{article}
\usepackage{pgfplots}
\usepackage{xargs}
\pgfplotsset{compat=1.6}
\def\El{5}
\def\WL{1.0}
\def\RA{1.0}
\def\IA{0.5}
\def\SE{0.45}
\def\In(#1){(2*pi/\WL)*\SE*cos(#1)*(180/pi)}
\def\FAR(#1){(\RA*cos(\In(#1))*(180/pi)+\IA*cos(\In(#1))*(180/pi))}
\def\FAI(#1){(\RA*sin(\In(#1))*(180/pi)+\IA*sin(\In(#1))*(180/pi))}
\def\FAM(#1){(\FAR(#1)^2+\FAI(#1)^2)^(1/2)}
% create the table contents:
\usepackage{longtable,array,siunitx,expl3}
\ExplSyntaxOn
\tl_new:N \tablecontents
\int_do_while:nn { \l_tmpa_int <= 360 }
{
\fp_set:Nn \l_tmpa_fp { round( \FAM( \l_tmpa_int * deg ) , 2 ) }
\fp_set:Nn \l_tmpb_fp { round( \FAI( \l_tmpa_int * deg ) , 2 ) }
\tl_put_right:Nx \tablecontents
{
\int_use:N \l_tmpa_int & % x
\fp_to_tl:N \l_tmpa_fp & % FAM(x)
\fp_to_tl:N \l_tmpb_fp \exp_not:N \\ % FAI(x)
}
\int_incr:N \l_tmpa_int
}
\ExplSyntaxOff
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[domain=0:360,red] { \FAM(x) } ;
\addplot[domain=0:360,blue] { \FAI(x) } ;
\end{axis}
\end{tikzpicture}
\begin{longtable}{l*2{S[table-format=-2.2]}}
$x$ & {$FAM(x)$} & {$FAI(x)$} \\ \hline
\endhead
\tablecontents
\end{longtable}
\end{document}
The first doubt that I have is how to define an array like a variable. I think that it's easy, but this doubt is related with the following doubt.
Now, I want to use an instruction in order to call some variables previously defined in my code, and in this way obtain some results. I know how to do that in MatLab, but in LaTeX it is different... I've installed the
xargs package in order to make this instruction.
So, imagine that I want to create this instruction with five arguments (
\El, \WL, \RA, \IA and \SE), and
\RA and \IA are the two variables that I want to define like two arrays (I mean, I want that this variables could take multiple values). So, I think the instruction could be something like that (I don't know if it's right):
Code: Select all
\newcommandx{\Instruction1}[5][1=,2=,3=,4=,5=]{\El \WL \RA \IA \SE}
With [5] I say the number of arguments that the instruction have; with [1=, 2=, ... 5=] I say the values that I want the arguments take; and with {\El \WL \RA \IA \SE} I specify the arguments to take into account.
But, like I said before, I want to define
\RA and \IA like two arrays, in the way \RA could be, for example, [0,1,1,1], and \IA could be, for example, [5,10,15,20], and I want to specify it in the instruction (I suppose that I've to define previously empty arguments). Do you know what I'm saying?
And finally, I want to make a call to this instruction, in the way:
And get like results the table of contents and the tikzpicture defined in the code:
Code: Select all
% create the table contents:
\usepackage{longtable,array,siunitx,expl3}
\ExplSyntaxOn
\tl_new:N \tablecontents
\int_do_while:nn { \l_tmpa_int <= 360 }
{
\fp_set:Nn \l_tmpa_fp { round( \FAM( \l_tmpa_int * deg ) , 2 ) }
\fp_set:Nn \l_tmpb_fp { round( \FAI( \l_tmpa_int * deg ) , 2 ) }
\tl_put_right:Nx \tablecontents
{
\int_use:N \l_tmpa_int & % x
\fp_to_tl:N \l_tmpa_fp & % FAM(x)
\fp_to_tl:N \l_tmpb_fp \exp_not:N \\ % FAI(x)
}
\int_incr:N \l_tmpa_int
}
\ExplSyntaxOff
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[domain=0:360,red] { \FAM(x) } ;
\addplot[domain=0:360,blue] { \FAI(x) } ;
\end{axis}
\end{tikzpicture}
\begin{longtable}{l*2{S[table-format=-2.2]}}
$x$ & {$FAM(x)$} & {$FAI(x)$} \\ \hline
\endhead
\tablecontents
\end{longtable}
\end{document}
But I don't know how to do...
Any idea??
Thank you so much
