Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
huh... looking for my ANSwer...

Subject: huh... looking for my ANSwer...

From: us

Date: 4 Feb, 2009 15:43:02

Message: 1 of 10

i have NOT seen this before

     clear ans;
     aval=pi;
     sum(aval)
     ans
%{
% returns
     aval = 3.1416... % <- sum(aval) ?????
     ans = 3.1416... % <- typical output
%}

     clear ans;
     sum([aval,aval])
%{
% returns - as expected
     ans = 6.2832...
%}

this happens with other functions as well, eg, PROD, etc.
why?

us

Subject: huh... looking for my ANSwer...

From: Matt Fig

Date: 4 Feb, 2009 15:59:03

Message: 2 of 10

What version are you using?
On 2007a:

clear ans;
     aval=pi;
     sum(aval)
     ans

ans =

       3.1416


ans =

       3.1416





bilq+sre_jq$hilbf|r7bJ^qb||`f^kBlm||d^^l|^^meel`$Vkl^_v|j=|

Subject: huh... looking for my ANSwer...

From: us

Date: 4 Feb, 2009 16:05:18

Message: 3 of 10

"Matt Fig"
> What version are you using?

sorry matt, i forgot this important info: 7.7.0.471/r2008b
urs

Subject: huh... looking for my ANSwer...

From: Matt Fig

Date: 4 Feb, 2009 16:15:19

Message: 4 of 10

This is the second (apparent) bug I have seen on cssm in as many days. And both cover very basic, long-time stable Matlab functionings! I am glad I didn't upgrade....


http://www.mathworks.com/matlabcentral/newsreader/view_thread/243612#625776





^TXeP)PcR__/|XcuT^P[n\V[^cud<\^ndnRQnnPP^TWZT]^nWQHPnWnh4P]

Subject: huh... looking for my ANSwer...

From: ImageAnalyst

Date: 4 Feb, 2009 17:15:18

Message: 5 of 10

On Feb 4, 10:43=A0am, "us " <u...@neurol.unizh.ch> wrote:
> i have NOT seen this before
>
> =A0 =A0 =A0clear ans;
> =A0 =A0 =A0aval=3Dpi;
> =A0 =A0 =A0sum(aval)
> =A0 =A0 =A0ans
> %{
> % returns
> =A0 =A0 =A0aval =3D 3.1416... % <- sum(aval) ?????
> =A0 =A0 =A0ans =3D 3.1416... % <- typical output
> %}
>
> =A0 =A0 =A0clear ans;
> =A0 =A0 =A0sum([aval,aval])
> %{
> % returns - as expected
> =A0 =A0 =A0ans =3D 6.2832...
> %}
>
> this happens with other functions as well, eg, PROD, etc.
> why?
>
> us

-----------------------------------------------------------------
I guess I don't understand what you think is wrong. You assign pi to
aval, and that's what is prints out. Then you sum it, but it's just a
single number, so the sum is the same as the number, which is again
pi, which is what you get. Then you have it print out ans (which
contains the contents of your previous call to sum()) and it again
prints out pi, which it should. Then you make a vector of two aval's
(two pi's) and you sum this and you get 2*pi, which, as you say, is
expected. So, to me, everything looks like you're getting what you
should. Can you explain what is unexpected?

Subject: huh... looking for my ANSwer...

From: Kenneth Eaton

Date: 4 Feb, 2009 17:40:18

Message: 6 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <f660f540-f9db-44b4-b803-0ad5f835c59d@t39g2000prh.googlegroups.com>...
> -----------------------------------------------------------------
> I guess I don't understand what you think is wrong. You assign pi to
> aval, and that's what is prints out. Then you sum it, but it's just a
> single number, so the sum is the same as the number, which is again
> pi, which is what you get. Then you have it print out ans (which
> contains the contents of your previous call to sum()) and it again
> prints out pi, which it should. Then you make a vector of two aval's
> (two pi's) and you sum this and you get 2*pi, which, as you say, is
> expected. So, to me, everything looks like you're getting what you
> should. Can you explain what is unexpected?

As it appears to me, when us calls "sum(aval)" it should display "ans = 3.1415...", but instead it displays "aval = 3.1415...". For some reason, it is taking the name of the variable input to sum and using that name to display the result of the sum. Am I right in interpreting that this is the problem, us?

Ken

Subject: huh... looking for my ANSwer...

From: Matt Fig

Date: 4 Feb, 2009 17:52:03

Message: 7 of 10

"Kenneth Eaton" <Kenneth.dot.Eaton@cchmc.dot.org> wrote in message
> For some reason, it is taking the name of the variable input to sum and using that >name to display the result of the sum. Am I right in interpreting that this is the >problem, us?
>
> Ken



I believe the output I showed above, obtained with 2007a, is the expected output.

Subject: huh... looking for my ANSwer...

From: Loren Shure

Date: 4 Feb, 2009 18:44:45

Message: 8 of 10

In article <gmcd26$3ph$1@fred.mathworks.com>, us@neurol.unizh.ch says...
> i have NOT seen this before
>
> clear ans;
> aval=pi;
> sum(aval)
> ans
> %{
> % returns
> aval = 3.1416... % <- sum(aval) ?????
> ans = 3.1416... % <- typical output
> %}
>
> clear ans;
> sum([aval,aval])
> %{
> % returns - as expected
> ans = 6.2832...
> %}
>
> this happens with other functions as well, eg, PROD, etc.
> why?
>
> us
>

I just reported this bug.

--
Loren
http://blogs.mathworks.com/loren

Subject: huh... looking for my ANSwer...

From: us

Date: 6 Feb, 2009 06:53:01

Message: 9 of 10

ImageAnalyst
> I guess I don't understand what you think is wrong. You assign pi to
> aval, and that's what is prints out...

imageanalyst
greetings and sorry for having obfuscated the issue with a lengthy post...

- ken correctly, as usual, got the point
     aval=pi;
     sum(aval)
% returns
% aval = 3.1416...
% but should(!) return
% ans = 3.1416...

- matt (fig) showed that this behavior did not (yet) show up in 2007a
- many a thanks to loren, who already put this issue onto the bug-trail...

as ever, best from zurich
urs

Subject: huh... looking for my ANSwer...

From: Dave Brackett

Date: 6 Feb, 2009 09:05:05

Message: 10 of 10

"us " <us@neurol.unizh.ch> wrote in message <gmgmod$d1a$1@fred.mathworks.com>...
> ImageAnalyst
> > I guess I don't understand what you think is wrong. You assign pi to
> > aval, and that's what is prints out...
>
> imageanalyst
> greetings and sorry for having obfuscated the issue with a lengthy post...
>
> - ken correctly, as usual, got the point
> aval=pi;
> sum(aval)
> % returns
> % aval = 3.1416...
> % but should(!) return
> % ans = 3.1416...
>
> - matt (fig) showed that this behavior did not (yet) show up in 2007a
> - many a thanks to loren, who already put this issue onto the bug-trail...
>
> as ever, best from zurich
> urs

I'm using 2008a and I can confirm that I also get this behaviour.

>> clear ans
>> aval=pi;
>> sum(aval)
aval =
    3.1416
>> ans
ans =
    3.1416

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us