help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior of octave and ans


From: Mike Miller
Subject: Re: Behavior of octave and ans
Date: Mon, 7 Jul 2014 13:28:48 -0400

On Mon, Jul 7, 2014 at 16:33:15 +0200, François Poulain wrote:
> Hi,
>
> Le Mon, 7 Jul 2014 10:07:51 -0400,
> Mike Miller <address@hidden> a écrit :
>
>> Since you are using eval, you could rewrite the user-input expression
>> to assign it to a particular named variable of your own choosing, and
>> get the result from its value. So for example
>>
>>   texmacs_result = a=1
>>   texmacs_result = b=a=1
>>   texmacs_result = a+1
>>
>> all update the variable texmacs_result. This should be equivalent to
>> what you were expecting the ans variable to be.
>>
>> Does that do what you need?
>
> Yes, but it may change the evaluation behaviour. As an example,
> texmacs_result = plot(1) behave differently from plot(1), and
> polyfit (1, 1, 1) behave differently from texmacs_result=
> polyfit (1, 1, 1).
>
> So, it is uneasy to guess when we should and when we should not add an
> assignation.

You're right of course, for functions with multiple return values or
whose behavior changes depending on nargout. I don't have an easy
answer for that, sorry :)

-- 
mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]