Hello
I have a problem with use 'syms' function
I want to execute the code below
-----------------------------
syms x y
f=x^2+y
__________________
but the error message 'Execute script syms as a function is not supported'
I have installed the symbolic toolbox. How can i execute the code??
thanks a lot

12 件のコメント

KSSV
KSSV 2022 年 2 月 3 日
編集済み: KSSV 2022 年 2 月 3 日
How did you try to run the lines of code? Show us the full code and your approach.
Jihun Gil
Jihun Gil 2022 年 2 月 3 日
編集済み: Jihun Gil 2022 年 2 月 3 日
syms x y
f=x^2+y
-----------------------
above is full code i tried. but the error message shown, and error is from line with ('syms x y')
I think syms function is not working, but I have no idea why.
I have symbolic math toolbox installed
KSSV
KSSV 2022 年 2 月 3 日
What does this show?
which syms
/MATLAB/toolbox/symbolic/symbolic/syms.m
Jihun Gil
Jihun Gil 2022 年 2 月 3 日
C:\Users\USER\Desktop\syms.m
this message shown
Jihun Gil
Jihun Gil 2022 年 2 月 3 日
C:\Program Files\MATLAB\R2021b\toolbox\symbolic\symbolic\@sym\sym.m % sym constructor
________________________________________________________________________________
when typing 'which sym', above message shown. What's the difference?
KSSV
KSSV 2022 年 2 月 3 日
In the path: @sym this might be creating a problem.... How did you install tool box?
Jihun Gil
Jihun Gil 2022 年 2 月 3 日
through the "addon explorer" on the upper tab of matlab programm. (sorry mine is in korean, I cannot sure that "addon explorer" is right term in english)
KSSV
KSSV 2022 年 2 月 3 日
I have no idea...I think the problem is with the path due @, but I am not sure. Let's see some one can answer the real solution.
Jihun Gil
Jihun Gil 2022 年 2 月 3 日
I got the problem! one of my old m-file was named 'syms.m'. I changed the name of that file, and 'syms' function works now. Sorry for bothering you with my foolish mistake, and i really appreciate your effort. thank you
KSSV
KSSV 2022 年 2 月 3 日
Huumh....thats the real problem. Good problem is solved.
Jihun Gil
Jihun Gil 2022 年 2 月 3 日
checking path of functions was helpful. appreciated!
Stephen23
Stephen23 2024 年 8 月 21 日
編集済み: Stephen23 2024 年 8 月 21 日
"I think the problem is with the path due @"
In fact the @ in the folder path simply tells us that the folder defines a class:
The actual problem was that the OP shadowed SYMS here:
and confirmed here:

サインインしてコメントする。

回答 (1 件)

Shubham
Shubham 2024 年 8 月 21 日

0 投票

Hi Jihun,
The error message you're seeing, "Execute script syms as a function is not supported," typically occurs when there is a conflict with the syms function. This usually happens if there is a script or a file named syms.m in your current directory or MATLAB path that is shadowing the built-in syms function from the Symbolic Math Toolbox.
Here are steps you can take to resolve this issue:
Steps to Resolve the Issue
  1. Check for Conflicting Files:
  • Use the which command to check if there is a conflicting file named syms.m in your path:
which syms -all
  • This command will list all instances of syms that MATLAB can find. Ensure that the first entry in the list is the built-in function from the Symbolic Math Toolbox.
2. Remove or Rename Conflicting Files:
  • If you find a syms.m file in your current directory or elsewhere in your MATLAB path that is not part of the Symbolic Math Toolbox, consider renaming or removing it to prevent conflicts.
3. Clear the Path Cache:
  • After removing or renaming any conflicting files, clear the path cache to refresh MATLAB's function path:
rehash toolboxcache

タグ

質問済み:

2022 年 2 月 3 日

編集済み:

2024 年 8 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by