Skip to main content
14-Alexandrite
February 2, 2012
Solved

For loop output to matrix

  • February 2, 2012
  • 1 reply
  • 26591 views

I am a beginner with programming in Mathcad. I am having trouble understanding how to use FOR Loops to dump results to a matrix from which I can extract values to plot in a graph. I wish to solve a non-linear equation and evaluate this function for a range of values and then graph the results in the form of a Bifurcation Diagram. The non-linear equation becomes chaotic at certain input force values.

I have constructed a Runge Kutta 4th order function to integrate the equation and develop the displacement and velocity time waveforms - no problem. As a first step I want to evaluate the equation for a range of forces and store the velocity (Y2) versus time (Y0) waveforms in a matrix. As a second stage I want to sample the velocity waveform after it has stabilised (after say 100 cycles) at periopdic intervals to see if the velocity amplitude remains stable or whether a chaotic behaviour occurs.

The attached Mathcad file has the integration front end and my attempt at a nested FOR loop to index the force amplitude and store the velocity (Y2) values in a matrix. The matrix output only seems to store the last iteration. I would appreciate if someone could get me over this first hurdle to evaluate all velocity waveforms for the range of forces 'A".

Extracting data to a new matrix after every N1 data points would be the next step and then plotting this data as aBifurcation Diagram.

Any assiatnce would be appreciated.

Cheers

Ross

Best answer by remslie

Alan,

I have been tinkering with a program that includes your ODEsolve suggestion -it is very effeicient!

I am trying to include a non-linear backlash (flatspot) into the displacement variable. As I understand the ODE solve block only allows first derivative experssions on LHS. Is there a way I can include a function thant modifies x(t) that includes the backlash - it is included in the attached sheet as g(t) just above the solve block.

Any ideas would be greatly appreciated.

Cheers

ross

1 reply

19-Tanzanite
February 2, 2012

You had the assignment to Xi,j in the wrong place.

Alan

remslie14-AlexandriteAuthor
14-Alexandrite
February 2, 2012

Alan,

Thankyou for your fast response. That was embarassingly easy to fix. I guess I am still somewhat confused with the syntax for nesting these FOR loops.If you are aware of an online reference that provides more on the topic than just the tutorial I would be keen to check it out. Thanks again

24-Ruby III
February 3, 2012

Some example can be found in the attachment (it's include material from "Mathcad Help" [hotkey F1]).