Unrecognized function or variable

조회 수: 2 (최근 30일)
Aijalon Marsh
Aijalon Marsh 2022년 3월 7일
답변: Davide Masiello 2022년 3월 7일
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