필터 지우기
필터 지우기

Getting an error "Error using erfc... Input must be real and full"

조회 수: 13 (최근 30일)
Shreya
Shreya 2023년 3월 24일
편집: Dyuman Joshi 2023년 3월 24일
This code is giving the error msg "Error using erfc... Input must be real and full"
Here PR = 0.71 so "a" will be neagtive.
a=M/(PR-1)
exp(-y*sqrt(a*PR)).*erfc(eta*sqrt(PR)-sqrt(a*t))+exp(y*sqrt(a*PR)).*erfc(eta*sqrt(PR)+sqrt(a*t))
How to rectify this problem?

답변 (2개)

Walter Roberson
Walter Roberson 2023년 3월 24일
편집: Walter Roberson 2023년 3월 24일
if a is negative and t is positive then sqrt(a*t) is square root of a negative value which is imaginary. You end up taking erfc of a complex value.
If you really need erfc of a complex value see https://www.mathworks.com/matlabcentral/answers/7153-erfc-with-complex-number#answer_9795

Dyuman Joshi
Dyuman Joshi 2023년 3월 24일
편집: Dyuman Joshi 2023년 3월 24일
The function erfc only supports real inputs (as evident by the error) and the input to erfc here is complex.
You can either use the symbolic erfc function, which requires Symbolic Math Toolbox. Note that you need to pass the input as symbolic number or symbolic variable.
Or you can use FEX file submissions -

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by