Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Why am i getting an error of too many output arguments

1 vue (au cours des 30 derniers jours)
Denny Mannakulathil
Denny Mannakulathil le 4 Oct 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
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));

Réponses (1)

Walter Roberson
Walter Roberson le 4 Oct 2020
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.

Cette question est clôturée.

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by