Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

indices of the maximum values in vector v

19 views
Skip to first unread message

aybike nurocak

unread,
Feb 10, 2012, 8:52:55 AM2/10/12
to
[y,v] = max(a) returns the indices of the maximum values in vector v
on Matlab. How can I do this on Maple 13 ?

a=[1 2+i]

a =

1.0000 2.0000 + 1.0000i

>> [c,d]=max(real(a))

c =

2


d =

2
I need to do the same on Maple..

Thanks

Joe Riel

unread,
Feb 10, 2012, 11:06:53 AM2/10/12
to
aybike nurocak <dilem...@gmail.com> writes:

> [y,v] = max(a) returns the indices of the maximum values in vector v
> on Matlab. How can I do this on Maple 13 ?
>
> a=[1 2+i]
>
> a =
>
> 1.0000 2.0000 + 1.0000i
>
>>> [c,d]=max(real(a))
>
> c =
>
> 2
>
>
> d =
>
> 2

You can use rtable_scanblock for this

V := <1,2,4,3>:
rtable_scanblock(V
, [rtable_dims(V)]
, (val,ind,res) -> `if`(val>res[2]
,[ind,val]
,res
)
, [ [1,1], V[1] ]
);
[[3], 4]

However, a simpler method is to use member

member(max(V),V,'pos');
true
pos;
3

--
Joe Riel
0 new messages