Trying to plot a function with changing variables.

1 vue (au cours des 30 derniers jours)
Tashiah
Tashiah le 27 Fév 2014
Réponse apportée : Sara le 27 Fév 2014
Below is my code and I am trying to plot time versus x. Every time i do plot(mbk(1,40)) it gives my the error too many outputs. Please help!!!
function mbk(m,k)
%-----variables--------- b=linspace(0,15,6); t=linspace(0,3,100);
%-----derived constants------ wn=sqrt(k/m); gamma= b/(2*m*wn); tau=wn*t;
%-----------------formulas----------- if (b==0) %Solve for x and plot t x Ty x=6*cos(tau)+ (3/wn)* sin(tau);
elseif b>0 %Solve for x and plot t x Ty if gamma==1 x= 6*exp(-tau)+ 3*tau*exp(-tau); hold on elseif gamma < 1 %Solve for x and plot t x Ty x = exp(-gamma*tau)*(6*cos(sqrt(1-gamma^2)*tau))... +((6*gamma-3)/sqrt(1-gamma^2))*sin(sqrt(1-gamma^2)*tau);
else gamma > 1;
x = exp(-gamma*tau)*(6*cos(sqrt(gamma^2-1)*tau))...
+((6*gamma-3)/sqrt(gamma^2-1))*sin(sqrt(gamma^2-1)*tau);
end
end

Réponses (1)

Sara
Sara le 27 Fév 2014
You are not returning any variables from the function mbk. Try: function [name_var_1,name_var_2] = mbk(m,k)

Catégories

En savoir plus sur Gamma Functions 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