Why do I receive legend error in matlab
22 次查看(过去 30 天)
显示 更早的评论
close all;
clear all;
clc
m=10;
b=5;
k=100;
F=100;
timerange=[0 20];
initialvalues=[0 0];
[t, x]=ode45(@second_order1,timerange,initialvalues);
figure
plot(t,x(:,1),'LineWidth',2)
ylabel('position(m),velocity(m/s),acceleration(m/s^2)')
xlabel('time(s)')
hold on
plot(t,x(:,2),'LineWidth',2,'LineStyle','-.')
hold on
plot(t,F/m-(b/m)*x(:,2)-(k/m)*x(:,1),'LineWidth',2,'LineStyle',':')
legend ('Position','Velocity','Acceleration')
0 个评论
回答(1 个)
Star Strider
2020-9-6
I cannot run yuour code, since I get:
Unrecognized function or variable 'second_order1'.
What is the error you are seeing?
5 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!