필터 지우기
필터 지우기

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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by