Lots of errors but code still runs fine?

3 visualizaciones (últimos 30 días)
Westin Messer
Westin Messer el 8 de Sept. de 2018
Comentada: Westin Messer el 8 de Sept. de 2018
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')

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 8 de Sept. de 2018
Editada: KALYAN ACHARJYA el 8 de Sept. de 2018
%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 comentario
Westin Messer
Westin Messer el 8 de Sept. de 2018
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)

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by