Iterations are taking too long
Afficher commentaires plus anciens
Hi,
My coding is taking too long to solve and I think that I have a lot of improvements which I can make. I am also a beginner in MATLAB and thus I require some help.
Basically I have a code that solves the motion of 3 DOF system. Similar to a mass on a spring. I have two for loops where one iterates for the force and the other iterates for the time response. I am solving the time response using the Newmark integration scheme. Now after that all iterations are done, the code requires that the results are written to an excel sheet for the three degrees of freedom together with plotting of graphs of the corresponding displacements.
I am using xlswrite for each degree of freedom meaning I have 3 xlswrite commands.
Are there any suggestions on how I can improve my computational time?
Thanks!
3 commentaires
José-Luis
le 24 Juin 2014
Lots of people might be able to help you if you show your code. Otherwise, we are limited to guessing.
One could just say: "Try a faster computer", for example.
Sara
le 24 Juin 2014
Use the profiler and find the bottleneck
Adam
le 24 Juin 2014
Using the Matlab profiler would be a good start point.
In its simplest form you can just put
profile on
...Your code...
profile off
profile viewer
to give you a run down of where in your code the time is being spent.
Then, in response to that there are many things you can possibly do, but until you find out where the time is actually being spent you may spend time optimising a piece of code that is only taking 0.1% of the total time.
Réponse acceptée
Plus de réponses (2)
Marisa Micallef
le 25 Juin 2014
Marisa Micallef
le 25 Juin 2014
0 votes
1 commentaire
Titus Edelhofer
le 26 Juin 2014
Hi,
U(i,j) means reading (or assigning) a single entry in the matrix at row i and column j. U(i,:) means reading (or assigning) a vector, namely the i-th row.
Titus
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!