Unrecognized function or variable

5 vues (au cours des 30 derniers jours)
Aijalon Marsh
Aijalon Marsh le 7 Mar 2022
So I have made a funtion and an m-file for calling that function but for some reason when I run the my m-file it says that the y is unrecognized below is my function and m-file please help me with this error:
Function:
function B2FrequencyResponse10(E, W, A)
K = 1;
t = (0:1.0:10)';
if (0 <= E) < 1
y = K*A-K*A*exp(-(e)*W*t)*(E/sqrt(1-E^2))*sin(W*sqrt(1-E^2)+cos(W*sqrt(1-E^2)));
if E == 1
y = K*A-K*A*(1+W*t)*exp(-(W)*t);
if E > 1
y = K*A-K*A*((E+sqrt(E^2-1))/2*sqrt(E^2-1)*exp(-(E)+sqrt(E^2-1)*W*t)+cos*(W*qrt(E^2-1)*t));
end
end
end
plot(t, y)
title('Step Response of Second-Order System')
xlabel('time')
ylabel('Output y(t)')
legend('E = 0')
end
m-file:
clear
E = 0;
W = 2;
A = 1;
hold on
B2FrequencyResponse10(E, W, A);

Réponse acceptée

Torsten
Torsten le 7 Mar 2022
function B2FrequencyResponse10(E, W, A)
K = 1;
t = (0:1.0:10)';
if E >= 0 & E < 1
y = K*A-K*A*exp(-(E)*W*t)*(E/sqrt(1-E^2))*sin(W*sqrt(1-E^2)+cos(W*sqrt(1-E^2)));
elseif E == 1
y = K*A-K*A*(1+W*t).*exp(-(W)*t);
elseif E > 1
y = K*A-K*A*((E+sqrt(E^2-1))/2*sqrt(E^2-1)*exp(-(E)+sqrt(E^2-1)*W*t)+cos*(W*sqrt(E^2-1)*t));
end
plot(t, y)
title('Step Response of Second-Order System')
xlabel('time')
ylabel('Output y(t)')
legend('E = 0')
end

Plus de réponses (1)

Davide Masiello
Davide Masiello le 7 Mar 2022
clear,clc
E = 0;
W = 2;
A = 1;
t = (0:1.0:10)';
y = B2FrequencyResponse10(t,E,W,A);
plot(t,y)
title('Step Response of Second-Order System')
xlabel('time')
ylabel('Output y(t)')
legend('E = 0')
function y =B2FrequencyResponse10(t,E,W,A)
K = 1;
if E >= 0 && E < 1
y = K*A-K*A*exp(-(E)*W*t)*(E/sqrt(1-E^2))*sin(W*sqrt(1-E^2)+cos(W*sqrt(1-E^2)));
elseif E == 1
y = K*A-K*A*(1+W*t)*exp(-(W)*t);
else
y = K*A-K*A*((E+sqrt(E^2-1))/2*sqrt(E^2-1)*exp(-(E)+sqrt(E^2-1)*W*t)+cos*(W*qrt(E^2-1)*t));
end
end

Catégories

En savoir plus sur Dynamic System Models dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by