Unrecognized function or variable

2 次查看(过去 30 天)
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);

采纳的回答

Torsten
Torsten 2022-3-7
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

更多回答(1 个)

Davide Masiello
Davide Masiello 2022-3-7
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

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by