I want to reuse values. Is there a similar functionality as %10 of Mathematica in Octave?

octave:18> 3/log (2)

ans = 4.32808512266689

octave:19> % //how to output 4.328....

octave:19> %%

octave:19> %18

link|improve this question

2  
Possibly better on StackOverflow. Admittedly, they only have 23 questions tagged [octave] and 48 tagged [mathematica], but it is still more than the here... – dmckee Oct 9 '09 at 1:01
feedback

1 Answer

up vote 3 down vote accepted

If you just need the last value calculated, the variable ans will do the job.

If you need it after several other calculations, you need to use the command run_history linenumber:

octave:9> 3/log(2)
ans =  4.3281
octave:10> 42
ans =  42
octave:11> 37
ans =  37
octave:12> run_history 9
ans =  4.3281

Then that value is in the ans variable and you can use it in a calculation:

octave:13> 2 * ans
ans =  8.6562

run_history is a command, not a function, so it doesn't seem to be usable directly in a calculation (or else I'm getting the syntax wrong). I'd love to hear about a more direct way if there is one.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.