Wie kann ich eine pgfplotstable erstellen, bei der die Tabelleneinträge entstehen, indem die Werte der 1. Zeile und der 1. Spalte addiert werden:

Öffne in Overleaf
x 0.1 0.2
1 1.1 1.2
2 2.1 2.2

und ggf. noch eine Funktion darauf anwenden, zum Beispiel:

Öffne in Overleaf
x 0.1 0.2
1 sin(1.1) sin(1.2)
2 sin(2.1) sin(2.2)

(wobei es die numerischen Werte anzeigen soll) oder irgendeine andere Funktion.

Öffne in Overleaf
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[margin=.25in]{geometry}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}

\begin{document}
\pagestyle{empty}

\pgfplotstabletypeset[sci zerofill]{
x 0.1 0.2
1 1.1 1.2
2 2.1 2.2
}

\pgfplotstabletypeset[sci zerofill]{
x 0.1 0.2
1 sin(1.1) sin(1.2)
2 sin(2.1) sin(2.2)
}

\end{document}

gefragt 22 Jul '17, 23:11

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%


Die neuen Spalten lassen sich auch in einer Schleife erzeugen:

Öffne in Overleaf
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[margin=.25in]{geometry}

\usepackage{pgfplotstable}
\pgfplotsset{compat=1.15}
%\pgfkeys{/pgf/trig format=rad}

\pgfplotstablenew[
  create on use/x/.style={create col/set list={0,...,9}},
  columns={x}
]{10}\loadedtable

\pagestyle{empty}
\begin{document}
\noindent\begingroup
\pgfplotsinvokeforeach{0,...,9}{%
  \pgfplotstablecreatecol[create col/expr={\thisrow{x}+#1/10}]{.#1}\loadedtable
}%
\pgfplotstabletypeset\loadedtable
\endgroup

\bigskip
\noindent\begingroup
\pgfplotsinvokeforeach{0,...,4}{%
  \pgfplotstablecreatecol[create col/expr={sin(\thisrow{x}+#1/10)}]{.#1}\loadedtable
}%
\pgfplotstabletypeset\loadedtable
\endgroup

\bigskip
\noindent\begingroup
\pgfplotsinvokeforeach{5,...,9}{%
  \pgfplotstablecreatecol[create col/expr={sin(\thisrow{x}+#1/10)}]{.#1}\loadedtable
}%
\pgfplotstabletypeset\loadedtable
\endgroup
\end{document}

alt text

Permanenter link

beantwortet 23 Jul '17, 04:51

esdd's gravatar image

esdd
17.7k254256
Akzeptiert-Rate: 62%

Dafür gibt es preproc/expr.

Öffne in Overleaf
\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}

\pgfplotstabletypeset[
sci zerofill,
columns/0.1/.style={preproc/expr={sin(##1)}},
columns/0.2/.style={preproc/expr={sin(##1)}},
]{
x 0.1 0.2
1 1.1 1.2
2 2.1 2.2
}

\end{document}

alt text

Um die Spalte aus der ersten und dem Spaltennamen zu erstellen muss man zwangläufig create col verwenden.

Öffne in Overleaf
\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}

\pgfplotstabletypeset[
sci zerofill,
create on use/0.1/.style={create col/expr={sin(\thisrow{x}+0.1)}},
create on use/0.2/.style={create col/expr={sin(\thisrow{x}+0.2)}},
columns={x,0.1,0.2},
]{
x
1
2
}

\end{document}
Permanenter link

beantwortet 23 Jul '17, 02:48

Henri's gravatar image

Henri
15.7k133943
Akzeptiert-Rate: 46%

bearbeitet 23 Jul '17, 02:57

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×39

gestellte Frage: 22 Jul '17, 23:11

Frage wurde gesehen: 5,121 Mal

zuletzt geändert: 23 Jul '17, 04:51