Thread Subject: imag and real don't work

Subject: imag and real don't work

From: Sandra

Date: 24 Jul, 2008 11:04:04

Message: 1 of 5

I am sure this must be a simple thing, but it is doing my
head in!!! imag and real don't work for me see below:

>> real(0.0116 + 0.3333i)
??? Subscript indices must either be real positive integers
or logicals.

>> real(2+3*i)
??? Subscript indices must either be real positive integers
or logicals.

>> imag(2+3*i)
??? Subscript indices must either be real positive integers
or logicals.


the last two are from the matlab example! what am I doing wrong?

any advice appreciated,
sandra

Subject: imag and real don't work

From: Dave Brackett

Date: 24 Jul, 2008 11:08:03

Message: 2 of 5

"Sandra " <smh31.nospam@sussex.ac.uk> wrote in message
<g69nj3$9he$1@fred.mathworks.com>...
> I am sure this must be a simple thing, but it is doing my
> head in!!! imag and real don't work for me see below:
>
> >> real(0.0116 + 0.3333i)
> ??? Subscript indices must either be real positive integers
> or logicals.
>
> >> real(2+3*i)
> ??? Subscript indices must either be real positive integers
> or logicals.
>
> >> imag(2+3*i)
> ??? Subscript indices must either be real positive integers
> or logicals.
>
>
> the last two are from the matlab example! what am I doing
wrong?


Check that you haven't assigned anything to i. i and j
should be reserved for complex numbers. type 'clear i' in
command window and then try again.
dave

Subject: imag and real don't work

From: John D'Errico

Date: 24 Jul, 2008 11:13:08

Message: 3 of 5

"Sandra " <smh31.nospam@sussex.ac.uk> wrote in message
<g69nj3$9he$1@fred.mathworks.com>...
> I am sure this must be a simple thing, but it is doing my
> head in!!! imag and real don't work for me see below:
>
> >> real(0.0116 + 0.3333i)
> ??? Subscript indices must either be real positive integers
> or logicals.
>
> >> real(2+3*i)
> ??? Subscript indices must either be real positive integers
> or logicals.
>
> >> imag(2+3*i)
> ??? Subscript indices must either be real positive integers
> or logicals.
>
>
> the last two are from the matlab example! what am I doing wrong?
>
> any advice appreciated,
> sandra

Every single new user does this. They create
a variable with the name of a function they
will later use.

Have you created variables named imag and
real? What should Matlab do when it sees
variables with that name, but you try to use
the functions of the same names?

Just for kicks, now create variables named
quit and exit, as well as clear. Make your life
interesting. ;-)

John

Subject: imag and real don't work

From: Bruno Luong

Date: 24 Jul, 2008 11:15:09

Message: 4 of 5

Rather check real and imag.

clear real imag % clear variables
which real
which imag

If it does not return built-in functions then you have a
files that overwrite MATLAB factory functions.

Bruno

Subject: imag and real don't work

From: Matt Fig

Date: 24 Jul, 2008 12:37:03

Message: 5 of 5

real = 1:4;
real(3+2*i)
??? Subscript indices must either be real positive integers
or logicals.

clear real
real(3+2*i)

ans =

     3

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
renamebuiltin Matt Fig 24 Jul, 2008 13:37:43
imag Sandra 24 Jul, 2008 07:05:08
real Sandra 24 Jul, 2008 07:05:08
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com