Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
EMERGENCY , *** False answer in MATLAB ****
조회 수: 4 (최근 30일)
이전 댓글 표시
MATLAB program calculates the value of q1 after 1 s wrong, for control, refer to page 4 PDF
댓글 수: 3
답변 (3개)
Star Strider
2014년 8월 26일
Structural engineering and earthquake simulations aren’t my areas of expertise, but there does seem to be a problem in the way you calculate q1. This is all worked out for you in detail on page 680.
Your kbar variable is obviously a matrix (as is P) so if you are solving for q(i+1) according to Equation 2.2 in Table 16.2.2 (and using its notation):
2.2 Kbar*q(i+1) = P(i+1)
you need to use the mldivide or (\) operator to solve for q(i+1):
q(i+1) = Kbar\P(i+1);
or in your code:
q1(i+1)=kbar\PH1;
See if this improves things.
Your kbar variable is a matrix (or should be), not a vector or scalar. You need to keep track of q1 and some other variables through various iterations, so subscript them. You don’t need to store successive values for PH1 or kbar, so there is no need to subscript them as they update. Just update them and be done with it for each iteration. I didn’t see any other obvious problems, but then I didn’t look closely.
댓글 수: 3
Image Analyst
2014년 8월 26일
tatina, did you try my suggestion? Or are you expecting Star to debug your code (which you have not given us) for you? Please read this http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer then attach your code and explain what "doesn't work" means to you.
Star Strider
2014년 8월 26일
편집: Star Strider
2014년 8월 26일
Thank you, IA.
tatina — According to the worked example on page 680, PH1 is (or should be a (2x1) vector, and kbar a (2x2) diagional matrix, so q1 should be a (2x1) vector.
Try creating q1 instead as:
q1(:,i+1) = kbar\PH1;
as step 2.2. Note that your q1 variable is actually [q1; q2] at every iteration.
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!