Unrecognized function or variable
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Aijalon Marsh
 il 7 Mar 2022
  
    
    
    
    
    Risposto: Davide Masiello
      
 il 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);
0 Commenti
Risposta accettata
  Torsten
      
      
 il 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
0 Commenti
Più risposte (1)
  Davide Masiello
      
 il 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
0 Commenti
Vedere anche
Categorie
				Scopri di più su Dynamic System Models in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!