I can't plot a function I created with respect for time

조회 수: 1 (최근 30일)
Areg Arzoomanian
Areg Arzoomanian 2020년 2월 22일
답변: Star Strider 2020년 2월 22일
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

답변 (1개)

Star Strider
Star Strider 2020년 2월 22일
You need to code it as an anonymous function. See Anonymous Functions for details.
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. .

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by