フィルターのクリア

Why does an error saying "Unrecognised function or variable" occrurs while solving a two variable polynomial equation numerically using vpasolve

1 回表示 (過去 30 日間)
I am trying to solve a bi variable polynomial equation x^4+3*x^2+x*t==0, where t is an independent variable and x is the dependent variable and I want to plot the results as well. So I use the help of vpasolve to get the results over a range of values for the independent variable 't'. I used the following code
clc;clear;close all;
sym x;
sym t;
t= 0.1:0.01:1;
for i= length(t)
S(i)= vpasolve(x^4+3*x^2+x*t==0,x);
end
Unrecognized function or variable 'x'.
plot(x,t)
If I run the above code I receive the following error
Unrecognized function or variable 'x'.
Error in sample_polynomial_equation_trial (line 6)
S(i)= vpasolve(x^4+3*x^2+x*t==0,x);
What correction should be done in order to get the code running? I am using MATLAB version R2020a

採用された回答

Star Strider
Star Strider 2022 年 1 月 30 日
Needs parentheses, single quotes, and some other tweaks —
% clc;clear;close all;
x = sym('x');
% sym(t);
t= 0.1:0.01:1;
for i= length(t)
S(:,i)= vpasolve(x^4+3*x^2+x*t(i)==0,x);
end
figure
subplot(2,1,1)
plot(t,real(double(S)))
grid
xlim([0.99 1.00])
subplot(2,1,2)
plot(t, imag(double(S)))
grid
xlim([0.99 1.00])
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by