EMERGENCY , *** False answer in MATLAB ****

MATLAB program calculates the value of q1 after 1 s wrong, for control, refer to page 4 PDF

3 件のコメント

Michael Haderlein
Michael Haderlein 2014 年 8 月 26 日
Please write here what the problem is. In case of zip files (and others) I'm a bit paranoid that a bad ugly computer virus might be hidden in there.
Also, in my opinion, writing in short what the important part of the code is, what comes out and what should come out is an important step to find the problem by yourself.
Reza
Reza 2014 年 8 月 26 日
I've uploaded the file again to make the system clean

回答 (3 件)

Star Strider
Star Strider 2014 年 8 月 26 日

0 投票

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
Image Analyst 2014 年 8 月 26 日
tatina's "Answer" moved here since it's not an answer to the original question:
I checked your eq: q1(i+1)=kbar\PH1; but this program did'nt work ; do you have other idea
Image Analyst
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
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.
Reza
Reza 2014 年 8 月 26 日

0 投票

Please, fix the program and send me , thank you very much rezabakhshi406@yahoo.com

この質問は閉じられています。

タグ

タグが未入力です。

質問済み:

2014 年 8 月 26 日

閉鎖済み:

2014 年 8 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by