I can not use i j k as a sym type what should I do

5 次查看(过去 30 天)
Error using syms (line 284)
Unable to create a symbolic variable 'i' by using 'syms' inside a MATLAB function because 'i' is an existing function name, class name, method name, and
so on. Use 'sym' instead.
I keep getting this error when I am trying to get this (x^2)*i+(y*j) equation from App designer.Firstly I get this equation as a string type and convert it to the sym to do sum mathematical calculations.
It works outside of the Appdesigner but when I try to write this to the appdesigner edit text, I got this error
How can I solve this ?

回答(1 个)

Askic V
Askic V 2022-12-16
编辑:Askic V 2022-12-16
This is how I would solve this problem:
c1 = test()
v1 = 
c1 = 
c1 = 
function c1 = test()
syms x y z k real
i = sym('i');
j = sym('j');
v1 = sym(dot([x^2 y z],[i j k]));
c1 = subs(v1,{x y z},{2 -3 2});
end
As you can see, i and j can be defined as symbolic variables inside the function. You just neen to use sym function.

类别

Help CenterFile Exchange 中查找有关 Symbolic Variables, Expressions, Functions, and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by