Need help creating dummy variables for plotting
조회 수: 3 (최근 30일)
이전 댓글 표시
Essentially what I'm doing is solving a force ODE using the Runge Kutta numerical integration method. In my code I have a vector, r, which is a position vector with initial values 0 such that r = [x,y,z]. Now I'm solving for r in this runge kutta algorithm and would like to plot all 3 components of the position at each point in time (i.e., plot the trajectory and not just the final point). For this I know I need to create a dummy variable(s). I was looking around but am finding it difficult to apply to my particular case.
I know it goes something like that the variable you'd like to plot and say it's force then your dummy variable would look something like dummyf = force(i); but for my r I have r(1) = x, r(2) = y and so on and so r(i) doesn't write out all 3 values of r at time step i, instead it selects the last value of the i-th (where i can only run from 1 to 3) component of r, which is not what I want at all.
I then tried writing dummy variables like x = r(1), y = r(2) and so on inside the for loop and then plotting them afterwards but to no avail. Then I wrote a second set of variables which I called dummyx, dummyy and dummyz which were defined like; dummyx = x(i); I figured since x was recording the value of r(1) at each time step then defining something as x(i) would plot the value of x at each i we iterate through. However this doesn't seem to be the case.. can anyone help me out here?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!