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

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

3 Comments

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.
I've uploaded the file again to make the system clean

Answers (3)

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 Comments

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
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.
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 on 26 Aug 2014
Please, fix the program and send me , thank you very much rezabakhshi406@yahoo.com

This question is closed.

Tags

No tags entered yet.

Asked:

on 26 Aug 2014

Closed:

on 26 Aug 2014

Community Treasure Hunt

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

Start Hunting!