Got Questions? Get Answers.
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:
arg function in matlab

Subject: arg function in matlab

From: vidya

Date: 25 Feb, 2011 05:45:35

Message: 1 of 6

we have to calculate least square estimate for geometrical transformation as follows

r=unit matrix
t=0
v = (i-(r*j)-t);
s=(norm(v).^2);

[r t]=arg( min(sum(s)));

how to use <arg> in matlab?.

Subject: arg function in matlab

From: Yumnam Kirani

Date: 25 Feb, 2011 08:18:04

Message: 2 of 6

"vidya " <vidya90rv@gmail.com> wrote in message <ik7flv$jl$1@fred.mathworks.com>...
> we have to calculate least square estimate for geometrical transformation as follows
>
> r=unit matrix
> t=0
> v = (i-(r*j)-t);
> s=(norm(v).^2);
>
> [r t]=arg( min(sum(s)));
>
> how to use <arg> in matlab?.

What your arg function intend to perform? What inputs it takes and what outputs it gives?
Yumnam Kirani Singh
Tronglaobi Awang Leikai

Subject: arg function in matlab

From: Think blue, count two.

Date: 25 Feb, 2011 08:41:00

Message: 3 of 6

On 24/02/11 11:45 PM, vidya wrote:
> we have to calculate least square estimate for geometrical
> transformation as follows
>
> r=unit matrix
> t=0
> v = (i-(r*j)-t);
> s=(norm(v).^2);
>
> [r t]=arg( min(sum(s)));
>
> how to use <arg> in matlab?.

In non-vectorized form:

function a = argument(z)
   re = real(z);
   im = imag(z);
   if im
     if re
       a = arctan(im/re);
     else
       a = sign(im) * pi/2;
     end
   else
     if re < 0
       a = pi;
     else
       a = 0;
     end
   end
end


There may well be a simpler way; I worked this up from the definition.

Subject: arg function in matlab

From: sheeba261991@gmail.com

Date: 5 Sep, 2013 10:08:12

Message: 4 of 6

1) 0<=t<255 is lower limit to argmax. how to use this in matlab coding. 2) before this the variable h(t),w(t)should be in these variables or it can be replaced by any other variable.. because i initialised for h(t) is p(thresh) and for w(t) is temp1. pls answer for these two questions.

Subject: arg function in matlab

From: Steven_Lord

Date: 5 Sep, 2013 13:28:48

Message: 5 of 6



<sheeba261991@gmail.com> wrote in message
news:9cc011c6-8da3-4ada-8eb7-b8afefe0ced3@googlegroups.com...
> 1) 0<=t<255 is lower limit to argmax. how to use this in matlab coding. 2)
> before this the variable h(t),w(t)should be in these variables or it can
> be replaced by any other variable.. because i initialised for h(t) is
> p(thresh) and for w(t) is temp1. pls answer for these two questions.

Are you using the ARGMAX function from this File Exchange submission?

http://www.mathworks.com/matlabcentral/fileexchange/24210-argmaxargmin

Rather than doing that, if you have the expression you want to minimize
stored as data, call MAX with two outputs.

x = randperm(10)
[maxValue, maxValueLocation] = max(x)

maxValue will be 10 and x(maxValueLocation) will be 10.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: arg function in matlab

From: eavranasa@gmail.com

Date: 24 Dec, 2013 11:52:35

Message: 6 of 6

function a = arg(z)
   re = real(z);
   im = imag(z);
   if re
       a=atan(im/re);
       if (re<0)
           if (im<0)
                a=-pi+a;
           else
               a=pi+a;
           end
       end
   else
       if(im>0)
           a=pi/2;
       else
           a=-pi/2;
       end
   end
          
 end

gives right results even when you give as input a complex number with negative real component in comparison with Walter Roberson's fuction

Tags for this Thread

No tags are associated with 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