Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!k13g2000prh.googlegroups.com!not-for-mail
From: TideMan <mulgor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: erf(x) troubles
Date: Tue, 3 Nov 2009 10:46:24 -0800 (PST)
Organization: http://groups.google.com
Lines: 45
Message-ID: <c81d173a-c0a3-4196-a974-1917705370ba@k13g2000prh.googlegroups.com>
References: <hcpss0$58s$1@fred.mathworks.com>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1257273984 31946 127.0.0.1 (3 Nov 2009 18:46:24 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 3 Nov 2009 18:46:24 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: k13g2000prh.googlegroups.com; posting-host=202.78.152.105; 
	posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
User-Agent: G2/1.0
X-HTTP-Via: 1.1 bc2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4) 
	Gecko/20091016 Firefox/3.5.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:582128


On Nov 4, 7:30 am, "Grant Ericson" <geric...@uncc.edu> wrote:
> Trying to plot a this function so I can thermal conductivity 'k':
>
> close all
> clear
>
> k = -1:.05:1;
>
> for j=1:length(k)
>
> A(j) = erf(.295099*k(j)^-.5);
> B(j) = exp(13.48325*k(j)^-1);
> C(j) = erf(3.68379*k(j)^-.5);
>
> D(j) = A(j)+B(j)-(B(j)*C(j))-(7/15);
>
> end
>
> plot(k,D)
>
> However, MATLAB keeps giving me this error message:
>
> ??? Error using ==> erfcore
> Input must be real.
>
> Error in ==> erf at 21
> y = erfcore(x,0);
>
> Error in ==> ht5_76 at 11
> y = erf(.295099*k(j)^-.5);
>
> Can someone help me out?  Apparently, I am not MATLAB-literate.
>
> Thanks.

Matlab is not the problem.
Your understanding of mathematics is the problem.
What happens when you take the square root of a negative number?
To demonstrate, do this in Matlab:
sqrt(-1)
You see the funny answer?  That is called a complex number.
It has a real part (the first bit) and an imaginary part (the bit
multiplied by i)
The error message Matlab is giving you is that erf only works with
real numbers.