Trying to plot a function with changing variables.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Sara
2014년 2월 27일
You are not returning any variables from the function mbk. Try: function [name_var_1,name_var_2] = mbk(m,k)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Gamma Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!