Lots of errors but code still runs fine?

조회 수: 3 (최근 30일)
Westin Messer
Westin Messer 2018년 9월 8일
댓글: Westin Messer 2018년 9월 8일
Hello,
I'm fairly new to Matlab and I wrote this scrip so solve a homework problem of mine. However when I run it I get a lot of errors that start on line 71 but my code only has 47 lines and it still runs perfectly fine. Can anyone tell me what might be going wrong and how I get rid of these errors. Thanks a lot!
clc
clear all
close all
fun=@(t,x) x.^3+x.^2-12*x;
figure (1)
fplot(@(x) fun(0,x),[-5,5])
grid on
xlabel('x'); ylabel('f(x)');
title('Function plot')
fp= solve(fun) % fixed point
[T X] = meshgrid(0:0.1:5, -5:0.1:5);
dY = fun(T,X);
dT = ones(size(dY));
L=sqrt(1+dY.^2);
figure (2)
quiver(T,X, dT./L, dY./L,0.5);
axis tight
xlabel('Time(t)'); ylabel('x(t)')
title('Stability graph')
[t1,x1] = ode45(fun,[0 5],0.1);
figure(3)
plot(t1,x1)
xlabel('Time (t)'); ylabel('x');
title('Solution at initial point x=0.1')

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 8일
편집: KALYAN ACHARJYA 2018년 9월 8일
%No Code Error
clc;
clear all;
close all;
fun=@(t,x) x.^3+x.^2-12*x;
figure, fplot(@(x) fun(0,x),[-5,5])
grid on
xlabel('x'); ylabel('f(x)');
title('Function plot')
fp=solve(fun) % fixed point
[T X]=meshgrid(0:0.1:5, -5:0.1:5);
dY=fun(T,X);
dT=ones(size(dY));
L=sqrt(1+dY.^2);
figure, quiver(T,X, dT./L, dY./L,0.5);
axis tight
xlabel('Time(t)'); ylabel('x(t)')
title('Stability graph')
[t1,x1]=ode45(fun,[0 5],0.1);
figure,plot(t1,x1)
xlabel('Time (t)'); ylabel('x');
title('Solution at initial point x=0.1')
  댓글 수: 1
Westin Messer
Westin Messer 2018년 9월 8일
hm you're not getting an error? I'm getting all this when I try and run it:
Undefined function or variable 'settings'.
Error in sympref (line 71)
s = settings;
Error in sym>symr (line 1365)
[S,err] = mupadmex(' ',x,3);
Error in sym>numeric2cellstr (line 1289)
S{k} = symr(double(x(k)));
Error in sym>tomupad (line 1246)
S = cell2ref(numeric2cellstr(x));
Error in sym (line 199)
S.s = tomupad(x);
Error in sym/privResolveArgs (line 948)
argout{k} = sym(arg);
Error in sym/privBinaryOp (line 972)
args = privResolveArgs(A, B);
Error in .^ (line 324)
B = privBinaryOp(A, p, 'symobj::zip', '_power');
Error in HW2_Attempt_1>@(t,x)x.^3+x.^2-12*x
Error in sym>funchandle2ref (line 1335)
S = x(S{:});
Error in sym>tomupad (line 1233)
x = funchandle2ref(x);
Error in sym (line 199)
S.s = tomupad(x);
Error in solve>getEqns (line 406)
a = sym(a);
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in HW2_Attempt_1 (line 9)
fp=solve(fun) % fixed point
Warning: Cannot initialize the symbolic preferences.
> In sym>symr (line 1365)
In sym>numeric2cellstr (line 1289)
In sym>tomupad (line 1246)
In sym (line 199)
In sym/privResolveArgs (line 948)
In sym/privBinaryOp (line 972)
In .^ (line 324)
In HW2_Attempt_1>@(t,x)x.^3+x.^2-12*x
In sym>funchandle2ref (line 1335)
In sym>tomupad (line 1233)
In sym (line 199)
In solve>getEqns (line 406)
In solve (line 226)
In HW2_Attempt_1 (line 9)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by