matplotlib​がインポートされてい​るユーザー定義のpy​thonをSimul​ink上で実行すると​エラー発生

4 views (last 30 days)
Yusuke Sakamaki
Yusuke Sakamaki on 27 Apr 2022
Edited: Yusuke Sakamaki on 2 Aug 2022
matplotlibがインポートされているユーザー定義のpythonをSimulink上で実行するとエラー発生します。
matlab再起動直後に発生します。matlabワークスペース上でmatplotlibのインポートは可能です。
暫定的にはmatplotlibを使用しない事としようと思いますが、
一度エラーが発生してしまうとユーザー定義関数が使用できなくなります。
トラブルの原因になるため、matlabの設定等で恒久的に対処する方法はありませんか?
【実行環境】
・Windows 10
・MATLAB R2021a update 6(最新アップデート)
・Python 3.8.10 
【simulinkモデル】
【MATLAB Function内のコード】
function y = fcn(u)
coder.extrinsic('test_plt')
test_plt
y = u;
【pythonモジュール呼び出し関数】test_plt.m
function test_plt()
py.test_matplotlib.dammycal(1,2)
end
【pythonのユーザー定義関数】test_matplotlib.py
import matplotlib.pyplot as plt
def dammycal(a,b):
return a+b
【エラーメッセージ】
  2 Comments
交感神経優位なあかべぇ
Windows11, MATLAB R2021b, R2020a、Python 3.8, Python 3.7環境でそれぞれ上記モデルを作成し、実施してみましたが、私の環境では正常に動作してしまい、原因の特定ができませんでした。
エラーが発生してしまったPython定義関数ですが、下記ページの「変更されたユーザー定義 Python モジュールの再読み込み」の手順に従うことで、再度使用可能になります。
Yusuke Sakamaki
Yusuke Sakamaki on 2 Aug 2022
Edited: Yusuke Sakamaki on 2 Aug 2022
情報提供ありがとうございます!
返信遅くなり申し訳ありませんでした。
実施いただいた環境では再現しなかったとのこと、了解しました。

Sign in to comment.

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!