Trying to plot a function with changing variables.
Show older comments
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
Answers (1)
Sara
on 27 Feb 2014
0 votes
You are not returning any variables from the function mbk. Try: function [name_var_1,name_var_2] = mbk(m,k)
Categories
Find more on Gamma Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!