Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why am i getting an error of too many output arguments

1 回表示 (過去 30 日間)
Denny Mannakulathil
Denny Mannakulathil 2020 年 10 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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));

回答 (1 件)

Walter Roberson
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.

この質問は閉じられています。

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by