matlab2tikz generates empty tikz-File when creating polarplot

14 ビュー (過去 30 日間)
Philo Kirsch
Philo Kirsch 2022 年 12 月 5 日
回答済み: Rohit 2023 年 3 月 21 日
Hallo all,
since several month I'm working with matlab2tikz and made good experiences. Right now, im trying to do a polarplot and convert it into a tikz-File to include it in Latex. The problem is, that matlab2tikz generates an empty tikz-File when creating a polarplot (see minimum example code). Does anyone have an idea how to solve the problem?
Kind regards
  • Minimum example code, that does not work:
clear all
close all
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)
matlab2tikz('C:\Users\Name\Desktop\Polarplot.tikz', 'height', '5cm', 'width', '5cm');
  • The file Polarplot.tikz without content looks like that:
% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\begin{tikzpicture}
\end{tikzpicture}%
  • The output from the matlab-console loosk like that:
*** (To disable info messages, pass ['showInfo', false] to matlab2tikz.)
*** (For all other options, type 'help matlab2tikz'.)
***
***
*** This is matlab2tikz v1.1.0.
***
*** The latest developments can be retrieved from our development branch.
*** You can find more documentation on our GitHub page and wiki.
*** If you encounter bugs or want a new feature, go to our issue tracker.
*** Please visit FileExchange to rate matlab2tikz or download the stable release.
***
*** You will need pgfplots version 1.3 or newer to compile the TikZ output.

回答 (1 件)

Rohit
Rohit 2023 年 3 月 21 日
The issue here is that when using the "polarplot" function in MATLAB, it generates a specific type of "PolarAxes" object that is not compatible with "matlab2tikz", resulting in the object not being translated properly.
However, there is a workaround possible: instead of using "polarplot", one can use the older "polar" syntax. "polar" creates a regular "Axes" object, which is then customized to resemble a polar plot.
Refer to below documentation links for these functions-

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by