1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Mathematicaで式が定義できないときの解決策:SetDelayed:のタグTimesはProtectedです.

Posted at

状況・課題

式の定義をしようとしたのに、以下のようなエラーコードが出てしまう。

f[x_] := x
SetDelayed:....のタグTimesProtectedです.

いや、定義してくださいよ...。

解決策

以下のコードで解決することができました!

Clear[x, f]

解説

原因

公式ドキュメントの

lhs:=rhs は,指定された割当てが実行可能な場合にはNullをその他の場合には$Failedを与える.

という文から、うまく変数への割り当てができていないことが原因と考えられます。

Clear

Clearは変数に与えられている値や式の定義をクリア(消去)する関数です。

引数に与えた変数をクリアしてくれます。今回の場合はftを指定しています。
これにより、うまく割り当てをできる状態になると考えられます。

参考

読んでいただき、ありがとうございました。

お役に立てたら嬉しいです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?