Sketch the analytical solution, using the formula below. HELP
이전 댓글 표시
clc
clear all
m=1
k=100
x0=5e-2
v0=30e-2
w=sqrt(k/m)
f=w/(2*pi)
t=1/f
n=10
x(1)=x0*cos(w*t)+(v0/w)*sin(w*t)
for n=2:n
x(n+1)=x(n-1)*cos(w*t(n-1))+(v0/w)*sin(w*t(n-1))
end
plot(t,x)
I am getting the error mesage "Index exceeds the number of array elements (1)." What am I doing wrong, please help
"
채택된 답변
추가 답변 (1개)
Image Analyst
2021년 12월 19일
0 개 추천
t is a scalar with value 0.6283. There is no second or third element of t so you can't index t with (n-1).
카테고리
도움말 센터 및 File Exchange에서 AI for Signals and Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!