I can't plot a function I created with respect for time
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I created this function "x(t)" with the given variables. Now I want to plot this function "x(t)" with respect to time and its not letting me.
%% Givens
m=2; %kg
k=200; %N/m
x0=0.05; %meters
x_dot=2; %m/s
%% Solution Part A
Wn= (k/m)^0.5;
c= (4*m*k)^0.5;
Cc= (2*m*Wn);
Zeta= c/Cc
%% Solution Part B
X= (((x0^2)*(Wn^2)+(x_dot^2)+(2*x0*x_dot*Zeta*Wn))^0.5)/(((1-(Zeta^2))^0.5)*Wn);
phi= atan((x_dot+(Zeta*Wn*x0))/(x0*Wn*((1-(Zeta^2))^0.5)));
Wd= ((1-(Zeta^2))^0.5)*Wn;
x(t)= X*(exp(-Zeta*Wn*t))* cos((Wd*t)-phi)
Please help
댓글 수: 0
답변 (1개)
Star Strider
2020년 2월 22일
Specifically:
x = @(t) X.*(exp(-Zeta.*Wn.*t)).* cos((Wd.*t)-phi)
Also, use element-wise operations just to be safe, unless you want to do matrix operations. See Array vs. Matrix Operations for those details.
Unfortunately, when I tried to plot it, it was Inf everywhere. You need to solve that problem. Note that ‘X’ is Inf as well, so that is likely the reason. .
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!