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!