필터 지우기
필터 지우기

Why do I get Inf for this complex expression?

조회 수: 1 (최근 30일)
Daniel Montgomery
Daniel Montgomery 2020년 6월 2일
답변: Ayden Clay 2020년 6월 2일
I have a function that generates a complex number but I get Inf for x. how could this be, if I do not make a logical error
for f=1:100
%a and b are struct passed by value, e.g. sturct(1).field
[R1,R2] = Prop(a(f),b(f),f,constant(f))
{e1=cell2mat(a)+cell2mat(b);
e2=cell2mat(a)-cell2mat(b);
w=(1-e1.*e2)./(e1-e2);}
end
  댓글 수: 2
Daniel Montgomery
Daniel Montgomery 2020년 6월 2일
e.g. sturct(1).field=1+j
e.g. sturct(1).field2=2+j3.5
David Goodmanson
David Goodmanson 2020년 6월 2일
Hi Daniel,
if you mean that you get inf for w, then on the basis of the information given the most obvious possibliity is that for at least one value of f the value of cell2mat(b) is zero.

댓글을 달려면 로그인하십시오.

답변 (1개)

Ayden Clay
Ayden Clay 2020년 6월 2일
Hi Daniel,
So in MATLAB there are only a few ways to get an output of "inf". The most common in equations is that we are dividing by zero.
In this case since w = (1-e1*e2)/(e1-e2), it must be the case that for some f, e1 = e2. This can only be the case if a+b = a-b which is only possible if b = -b, which is only possible if b = 0.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by