Why this ERROR is coming

M=1;Kp=100;
P2=M+(1/Kp);P3=P2+1i*w;
U7=exp(y*sqrt(P3)).*(1-erf(y/(2*sqrt(t))+ sqrt(P3*t)));
Error using erf (error function)
Input must be real and full.
Error in
U7=exp(y*sqrt(P3)).*(1-erf(y/(2*sqrt(t))+ sqrt(P3*t)));

8 comentarios

KSSV
KSSV el 30 de Abr. de 2019
Undefined function or variable 'w'.
MINATI
MINATI el 30 de Abr. de 2019
Editada: MINATI el 30 de Abr. de 2019
oooh sorry
w=1; t=1;
y=0:0.1:5;
KSSV
KSSV el 30 de Abr. de 2019
Undefined function or variable 'y'.
MINATI
MINATI el 30 de Abr. de 2019
Already given
y=0:0.1:5;
KSSV
KSSV el 30 de Abr. de 2019
Read about erf it accepts only real......in your case the input is complex.
MINATI
MINATI el 30 de Abr. de 2019
ok
Walter Roberson
Walter Roberson el 30 de Abr. de 2019
There is a way you can get around the restriction. If you use the symbolic toolbox, then the erf() function for it accepts complex inputs. To use the symbolic toolbox, at least part of the expression needs to be symbolic. For example if instead of sqrt(P3*t) you used sym(sqrt(P3*t)) then that would be enough. The result of the erf would be symbolic, so you would probably want to double() it.
Torsten
Torsten el 30 de Abr. de 2019
Or maybe another alternative:
https://de.mathworks.com/matlabcentral/fileexchange/18312-error-function-of-complex-numbers

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 30 de Abr. de 2019

Comentada:

el 30 de Abr. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by