Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

4 visualizzazioni (ultimi 30 giorni)
Reza
Reza il 26 Ago 2014
Chiuso: Matt J il 26 Ago 2014
MATLAB program calculates the value of q1 after 1 s wrong, for control, refer to page 4 PDF
  3 Commenti
Reza
Reza il 26 Ago 2014
I've uploaded the file again to make the system clean

Risposte (3)

Image Analyst
Image Analyst il 26 Ago 2014

Star Strider
Star Strider il 26 Ago 2014
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 Commenti
Image Analyst
Image Analyst il 26 Ago 2014
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 il 26 Ago 2014
Modificato: Star Strider il 26 Ago 2014
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 il 26 Ago 2014
Please, fix the program and send me , thank you very much rezabakhshi406@yahoo.com

Questa domanda è chiusa.

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by