Lots of errors but code still runs fine?
1 view (last 30 days)
Show older comments
Westin Messer
on 8 Sep 2018
Commented: Westin Messer
on 8 Sep 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')
0 Comments
Accepted Answer
KALYAN ACHARJYA
on 8 Sep 2018
Edited: KALYAN ACHARJYA
on 8 Sep 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')
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!