I have the following matrix
$$\begin{bmatrix}
k_{11}(y_1) & k_{12} (y_2) & \hdots & k_{1N_S} (y_{N_S}) \\
k_{21}(y_2) & \ddots & & \vdots \\
\vdots & & \ddots & \vdots \\
k_{N_S1}(y_{N_S}) & \hdots & \hdots & k_{N_SN_S} (y_{N_S})
\end{bmatrix}$$
where each element is computed at a point in a non-uniform mesh $y_j$, $j=1,\hdots, N_S$
I want to interpolate this matrix (second order) to a new mesh, say $z_j$, $j=1,\hdots, N_D$, with $N_D<N_S$, so that the new matrix will be
$$\begin{bmatrix}
k^*_{11}(z_1) & k^*_{12} (z_2) & \hdots & k^*_{1N_D} (z_{N_D}) \\
k^*_{21}(z_2) & \ddots & & \vdots \\
\vdots & & \ddots & \vdots \\
k^*_{N_S1}(z_{N_D}) & \hdots & \hdots & k^*_{N_DN_D} (z_{N_D})
\end{bmatrix}$$
where $k^*_{ij}$ are the corresponding interpolated values of $k_{ij}$.
How can I do this in MATLAB?
Related
I'm having an issue where at certain points using the \hline function creates an error and instead displays the word "height" where there should be a line. This is happening only when I use an /hline immediately after using a \input{".../filename.tex"} command in a tabular environment. Interestingly, though, adding an \hline to the last row of the file I am importing produces an \hline properly. Does anyone have an idea why this may be the case and what I can do to fix it so that I can add the \hline to the main file and not the files I'm importing. Note that I use TexMaker and MiKTeX
Here are some examples of my code that doesn't work:
\documentclass{12pt, english}{article}
\usepackage{geometry}
\usepackage{caption}
\usepackage{tocvsec2}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{subfloat}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{tabu}
\usepackage{titlesec}
\usepackage{tocloft}
\begin{document}
\begin{table}
\caption{Caption} \label{tab:label} \centering
\begin{tabular}{lccc}
\hline
\import{".../filename.tex"}
\hline
\end{tabular}
\begin{minipage}{0.95}
Notes are here
\end{minipage}
\end{table}
\end{document}
where filename.tex looks like this (with nothing else):
& Mean & SD & N \\
\midrule
Var 1 & 1 & 0 & 1000 \\
Var 2 & 1 & 0 & 1000 \\
Var 3 & 1 & 0 & 1000 \\
Var 4 & 1 & 0 & 1000 \\
Var 5 & 1 & 0 & 1000 \\
When I move the last \hline to the end of filname.tex, however, it works fine.
You can use the same trick as in https://tex.stackexchange.com/a/50700/36296
Other problems:
the syntax \documentclass{12pt, english}{article} is wrong
the booktabs package is missing
missing unit in \begin{minipage}{0.95}
you really, really, really shouldn't use the tabu package, it is more or less completely broken
don't load the same package multiple times
\documentclass[12pt, english]{article}
\usepackage{geometry}
\usepackage{caption}
\usepackage{tocvsec2}
\usepackage{graphicx}
\usepackage{multirow}
%\usepackage{tabularx}
\usepackage{subfloat}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{tabulary}
%\usepackage{tabu}
\usepackage{titlesec}
\usepackage{tocloft}
\usepackage{booktabs}
\begin{filecontents*}[overwrite]{test.tex}
& Mean & SD & N \\
\midrule
Var 1 & 1 & 0 & 1000 \\
Var 2 & 1 & 0 & 1000 \\
Var 3 & 1 & 0 & 1000 \\
Var 4 & 1 & 0 & 1000 \\
Var 5 & 1 & 0 & 1000 \\
\end{filecontents*}
\makeatletter
\newcommand\primitiveinput[1]
{\##input #1 }
\makeatother
\begin{document}
\begin{table}
\caption{Caption} \label{tab:label} \centering
\begin{tabular}{lccc}
\hline
\primitiveinput{test}
\hline
\end{tabular}
\begin{minipage}{0.95cm}
Notes are here
\end{minipage}
\end{table}
\end{document}
I am writing an article and the template is in LaTeX, and I need to insert a multicolumn table, the problem is, I have knowledgement just with the basics about LaTeX writing and i am finding some trouble with the organisation of the columns.
This is how the table should look like (image inside Word doc): Word
And this is how the code that i am using is being compiled inside LaTeX: LaTeX
Here is the code:
\begin{table*}[!htb]
\centering%
\caption{ParĂ¢metros obtidos para o ajuste utilizando o modelo de Langmuir.}%
\label{tab:resul}
\centering%
\begin{tabular}{c c c c}
\hline
Modelo de Langmuir:
\begin{minipage}{7cm}{\begin{equation}\label{eq:Uxy}
\frac{\\Qmax\ K_L Ceq}{\\1\ +K_L Ceq} = Qe
\end{equation}}
\end{minipage} \\
\cline{1-4}
\multicolumn{2}{c|}{\textbf{HDL Calc}} & \multicolumn{2}{c}{\textbf{HDL SDS Calc}} \\
\hline
Qmax & K(L/mg) & Qmax(mg/g) & K(L/mg)\\
\hline
690,6 & 0,011 & 132,3 & 0,136\\
\bottomrule
\addlinespace
\end{tabular}
\fonte{Autoria prĂ³pria (2021).}
\end{table*}
Any help with the code?
I want to get this snippet to work :
"General matrix": {
"prefix": "general-matrix-n-n-with-a-elements",
"body": [
"\\begin{equation}",
"\t \\begin{bmatrix}",
"\t\t a_{11} & a_{12} & a_{13} & \\dots & a_{1n} \\\\ ",
"\t\t a_{21} & a_{22} & a_{23} & \\dots & a_{2n} \\\\ ",
"\t\t \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\ ",
"\t\t a_{n1} & a_{n2} & a_{n3} & \\dots & a_{nn}",
"\t \\end{bmatrix}",
"\\end{equation}",
],
"description": "General n by n matrix"
So that it formats to this
\begin{equation}
\begin{bmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n} \\
a_{21} & a_{22} & a_{23} & \dots & a_{2n} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & a_{n3} & \dots & a_{nn}
\end{bmatrix}
\end{equation}
But the backslashes are formatting to this
\begin{equation}
\begin{bmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n} \
a_{21} & a_{22} & a_{23} & \dots & a_{2n} \
\vdots & \vdots & \vdots & \ddots & \vdots \
a_{n1} & a_{n2} & a_{n3} & \dots & a_{nn}
\end{bmatrix}
\end{equation}
Note that there's not a double \\ at the end of the lines but a single \
Just add two more backslashes as in:
"General matrix": {
"prefix": "general-matrix-n-n-with-a-elements",
"body": [
"\\begin{equation}",
"\t \\begin{bmatrix}",
"\t\t a_{11} & a_{12} & a_{13} & \\dots & a_{1n} \\\\\\ ",
"\t\t a_{21} & a_{22} & a_{23} & \\dots & a_{2n} \\\\\\ ",
"\t\t \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\\ ",
"\t\t a_{n1} & a_{n2} & a_{n3} & \\dots & a_{nn}",
"\t \\end{bmatrix}",
"\\end{equation}",
],
"description": "General n by n matrix"
}
Each backslash in a snippet that you want printed needs to be double-escaped, so that is 2 extra per each backslash for a total of 6 if you want 2 outputted.
I want to create something like this in MS Word by MathType 6.9
The code that I'm using is:
\documentclass[a4paper]{book}
\usepackage{geometry}
\usepackage{amsmath}
\begin{document}
\begin{align}
T_4 &= \langle \underline{k}\,.\,\underline{k}^{*^T} \rangle=
\left\langle
\begin{bmatrix}
\left|k_1\right|^2 & k_1k_2^* & k_1k_3^* & k_1k_4^* \\
k_2k_1^* & \left|k_2\right|^2 & k_2k_3^* & k_2k_4^* \\
k_3k_1^* & k_3k_2^* & \left|k_3\right|^2 & k_3k_4^* \\
k_4k_1^* & k_4k_2^* & k_4k_3^* & \left|k_4\right|^2
\end{bmatrix}
\right\rangle
\\
&=\frac{1}{2}
\begin{aligned}[t]
& \left[\begin{matrix}
\langle|S_{XX}+S_{YY}|^2\rangle &
\langle(S_{XX}+S_{YY})(S_{XX}-S_{YY})^*\rangle &\\
\langle(S_{XX}-S_{YY})(S_{XX}+S_{YY})^*\rangle &
\langle|S_{XX}-S_{YY}|^2\rangle & \cdots\cdots\\
\langle(S_{XY}+S_{YX})(S_{XX}+S_{YY})^*\rangle&
\langle(S_{XY}+S_{YX})(S_{XX}-S_{YY})^*\rangle & \cdots\cdots\\
\langle j(S_{XY}-S_{YX})(S_{XX}+S_{YY})^*\rangle &
\langle j(S_{XY}-S_{YX})(S_{XX}-S_{YY})^*\rangle &
\end{matrix}\right.\\
& \left.\begin{matrix}
& \langle(S_{XX}+S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}+S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle(S_{XX}-S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}-S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle|S_{XY}+S_{YX}|^2\rangle
& \langle-j(S_{XY}+S_{YX})(S_{XY}-S_{YX})^*\rangle\\
& \langle j(S_{XY}-S_{YX})(S_{XY}+S_{YX})^*\rangle
& \langle|S_{XY}-S_{YX}|^2\rangle
\end{matrix}\right]
\end{aligned}
\end{align}
\end{document}
It's perfect when used in LaTeX and gives the following pdf result:
but unfortunately when I try to copy and paste the code between \begin{document} and \end{document} in MathType to create the same expression in word, I get the result:
It seems that MathType doesn't parse the codes \begin{aligned}[t] and \end{aligned} and as you know these are just amsmath packages code.
Do you know of any way -modifying the code or mathtype settings- to solve this problem?
Or do you have another suggestion to embed Latex equation into MS Word 2010?
Here is a toned-down version of your construction that doesn't use aligned:
\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{amsmath}
\begin{document}
\begin{align}
T_4 &= \langle \underline{k}\,.\,\underline{k}^{*^T} \rangle=
\left\langle
\begin{bmatrix}
|k_1|^2 & k_1k_2^* & k_1k_3^* & k_1k_4^* \\
k_2k_1^* & |k_2|^2 & k_2k_3^* & k_2k_4^* \\
k_3k_1^* & k_3k_2^* & |k_3|^2 & k_3k_4^* \\
k_4k_1^* & k_4k_2^* & k_4k_3^* & |k_4|^2
\end{bmatrix}
\right\rangle \\
&= \frac{1}{2}
\left[\begin{matrix}
\langle|S_{XX}+S_{YY}|^2\rangle &
\langle(S_{XX}+S_{YY})(S_{XX}-S_{YY})^*\rangle &\\
\langle(S_{XX}-S_{YY})(S_{XX}+S_{YY})^*\rangle &
\langle|S_{XX}-S_{YY}|^2\rangle & \cdots\cdots\\
\langle(S_{XY}+S_{YX})(S_{XX}+S_{YY})^*\rangle&
\langle(S_{XY}+S_{YX})(S_{XX}-S_{YY})^*\rangle & \cdots\cdots\\
\langle j(S_{XY}-S_{YX})(S_{XX}+S_{YY})^*\rangle &
\langle j(S_{XY}-S_{YX})(S_{XX}-S_{YY})^*\rangle &
\end{matrix}\right. \nonumber \\
& \phantom{{}= \frac{1}{2}}
\left.\begin{matrix}
& \langle(S_{XX}+S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}+S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle(S_{XX}-S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}-S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle|S_{XY}+S_{YX}|^2\rangle
& \langle-j(S_{XY}+S_{YX})(S_{XY}-S_{YX})^*\rangle\\
& \langle j(S_{XY}-S_{YX})(S_{XY}+S_{YX})^*\rangle
& \langle|S_{XY}-S_{YX}|^2\rangle
\end{matrix}\right]
\end{align}
\end{document}
It's not possible to test this without access to MathType. So, while the above doesn't use aligned, you may have to remove some commands that are unknown to MathType.
In a matlab script, I'm generating a latex table. A part of that table for example looks likes this.
\multirow{2}{*}{\textbf{b1}}
&
2 & 3 & 10092 & 10763 & 103390 & 2797 & 2929 & 3008 & 5\% & 8\% \\
& 4 & 2 & 20184 & 10763 & 74508 & 1830 & 1970 & 2029 & 8\% & 11\% \\
This string is saved in variable str. Now when I try to write str to a file by using the following code.
f = fopen( 'report\results.tex', 'w' );
fprintf( f, str );
fclose(f);
I get the following warning.
Warning: Invalid escape sequence appears in format string.
See help sprintf for valid escape sequences.
That is probably due to many backslash characters in my string, which is used as escape sequence. Now how can I print this string to a file as it is.
escape the backslashes and percent signs:
str = strrep(str,'\','\\');
str = strrep(str,'%','%%');
If it's just text your printing, this'll be fine.
Minimal working example:
str = '2 & 3 & 10092 & 10763 & 103390 & 2797 & 2929 & 3008 & 5\% & 8\% \\'
str = strrep(str,'\','\\');
str = strrep(str,'%','%%');
f=fopen('testing123.txt','w');
fprintf(f,str);
fclose(f);
and the file reads:
2 & 3 & 10092 & 10763 & 103390 & 2797 & 2929 & 3008 & 5\% & 8\% \\
OR as Ben A. suggests, use fwrite:
fwrite(f,str)
and I think
fprintf(f,'%s',str)
will also do the trick, and it's best to also include a newline:
fprintf(f,'%s\n',str)