error when use 'x' created by syms method: 输入参数的数目不足。 出错 digits (第 15 行) f = func; 出错 sym/display (第 12 行) if ~isempty(useDigits) && useDigits ~= digits()

5 次查看(过去 30 天)
When enter the code like:
syms x
then:
equ = 2*x==9
It is pop a error:
输入参数的数目不足。(Insufficient number of input parameters)
出错 digits (第 15 行) (error digits (line 15))
f = func;
出错 sym/display (第 12 行) (error sym/display (line 12))
if ~isempty(useDigits) && useDigits ~= digits()
When I write above code with colon (;), there is no error but the result is not what I want to.
In each case it will plot an empty figure for me which is confused. In other machine it will work appropriately, but I failed after update and reinstall my matlab and toolbox and reboot the computer.
  4 个评论
Boheng Zhao
Boheng Zhao 2023-12-2
Accually when I run any example of solve method given by matlab official document it cannot run and giving a such error, not like the result given by the document shown. When I add colon for equ = 2*x==9;, it will have no error and equ is 1*1sym. However, when click into it, there is a empty plot which can not close and have a comment: unable to reference the variable. It is wired.
Dyuman Joshi
Dyuman Joshi 2023-12-29
编辑:Dyuman Joshi 2023-12-29
@Boheng Zhao, Run this command and see if the code works afterwords -
restoredefaultpath;
rehash toolboxcache;

请先登录,再进行评论。

回答(1 个)

SAI SRUJAN
SAI SRUJAN 2023-12-28
Hi Boheng,
I understand that you are facing an error with the symbolic toolbox.
It looks like you're encountering an issue with MATLAB's symbolic toolbox, specifically when trying to define and display a symbolic equation. The error suggests there might be a problem with your MATLAB installation or with the symbolic toolbox itself, especially since you mention that the code works on another machine.The error messages seem to be pointing to an issue with the 'digits' function, which is related to variable-precision arithmetic and not directly related to defining symbolic variables or equations.
Ensure that there are no user-defined functions or scripts in your MATLAB path that might be overriding the built-in 'digits' or 'display' functions. You can check this by running:
which digits -all
which display -all
It is recommended to update MATLAB to the latest version and restart the software, as this may resolve any potential conflicts or compatibility issues. If the problem persists, reinstalling the Symbolic Math Toolbox might be necessary to ensure all necessary files and dependencies are properly installed.
Please use the following commands to check the proper installation of Symbolic Math Toolbox,
which sym
For a comprehensive understanding of the 'which' command in MATLAB, please refer to the following documentation.
I hope this helps.

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!