Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why am i getting an error of too many output arguments
1 次查看(过去 30 天)
显示 更早的评论
clc;
clear all;
close all;
dt = [0.5 0.1 0.01];
for j = 1:length(dt)
t = 0:dt(j):10;
u = ones(1,length(t));
y(1) = 0;
dy(1) = 0;
for i = 1:length(t)-1
ddy(i) = u(i) - 3*dy(i) - 2*y(i);
dy(i+1) = ddy(i)*dt(j) + dy(i);
y(i+1) = dy(i)*dt(j) + y(i);
end
ya = 0.5*u + 0.5*exp(-2*t) - exp(-t);
e = ya - y;
figure(j*i)
title('Unit Step Function')
plot(t,y,'--+')
hold on
plot(t,ya,'--o')
xlabel('Time(s)','Fontsize',14,'FontWeight','bold','Color','b')
ylabel('Y','Fontsize',14,'FontWeight','bold','color','b')
str = {'\delta(t) = ',num2str(dt(j))};
text(t(fix(length(t)/2)),max(ya)/2,str);
legend('Numerical Solution','Analytical Solution')
box on
grid on
figure(j*(i+1))
title('Unit Step Function')
hold on
plot(t,e,'--o')
xlabel('Time(s)','Fontsize',14,'FontWeight','bold','Color','b')
ylabel('error','Fontsize',14,'FontWeight','bold','color','b')
e_max(j)= max(abs(error));
box on
grid on
end
% I get the error in the line e_max(j) = mac(abs(error));
0 个评论
回答(1 个)
Walter Roberson
2020-10-4
e_max(j)= max(abs(error));
You do not have any variable named error, so you are calling the function error() expecting an output but error() does not define any outputs.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!