I can't figure out why I am getting the error message Matrix dimensions must agree.
조회 수: 1 (최근 30일)
이전 댓글 표시
clc;
k=48000;
m=1200;
c=[3000:1000:10000];
w=sqrt(k/m);
E=c/(2*sqrt(m*k));
a=sqrt(1-E.^2)*w;
b=E/(sqrt(1-E.^2));
f0=9000/100;
d=E*w;
t=[0:0.05:10];
x=f0-f0.*exp(-d.*t).*cos(a.*t)-(f0*b).*exp(-d.*t).*sin(a.*t);
plot(t,x);
ylabel('Frequency of Suspension');
xlabel('Time (s)');
title('Frequency of Car Suspension')
댓글 수: 0
채택된 답변
Star Strider
2018년 9월 25일
The problem is that ‘c’ and everything you calculate from it are (1x8) vectors and ‘t’ is a (201x1) vector. Your ‘x’ assignment works if you transpose ‘a’ and ‘d’ to column vectors:
a=sqrt(1-E'.^2)*w;
d=E'*w;
It then plots a family of curves.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!