|
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.
|