ROOTS 的输入不能包含 NaN 或 Inf。

조회 수: 9 (최근 30일)
艳荣
艳荣 2023년 5월 17일
댓글: 艳荣 2023년 9월 25일
你好,我是用matlab function实现大致如下的功能代码,运行后报错:ROOTS 的输入不能包含 NaN 或 Inf。请问有没有什么解决方法,谢谢!
function [Pa1,Pa2]=Blend(pa)
F=AeroFun;
n=pa.m2/pa.m1;
Cp1=pa.gamma1*pa.R1/(pa.gamma1-1);
Cp2=pa.gamma2*pa.R2/(pa.gamma2-1);
c=Cp2/Cp1;
theta=pa.T02/pa.T01;
m3=pa.m2+pa.m1;
Cp3=(Cp1+n*Cp2)/(1+n);
T03=(1+n*c*theta)*pa.T01/(1+n*c);
R3=(pa.R1+n*pa.R2)/(1+n);
a01=(pa.gamma2/pa.gamma1)+n*c;
gamma3=pa.gamma2*(1+n*c)/a01;
P01_ratio=F.Pi(pa.lamda2,pa.gamma2)/F.Pi(pa.lamda1,pa.gamma1);
a02=F.C(pa.R2,pa.gamma2)*F.q(pa.lamda2,pa.gamma2);
a03=F.C(pa.R1,pa.gamma1)*P01_ratio*F.q(pa.lamda1,pa.gamma1);
a04=a02/(a03*(theta^0.5));
A_ratio=a04/(n+a04);
a05=((pa.gamma1+1)*pa.R1/(2*pa.gamma1))^0.5;
a06=((pa.gamma2+1)*pa.R2/(2*pa.gamma2))^0.5;
a07=((gamma3+1)*R3/(2*gamma3))^0.5;
a08=n*theta^0.5;
a09=(1+n)*((1+n*c*theta)/(1+n*c))^0.5;
a10=(a05*F.Z(pa.lamda1)+a06*a08*F.Z(pa.lamda2))/(a07*a09);
a11=[1 -a10 1];
lamda_root=roots(a11);

채택된 답변

Ayush
Ayush 2023년 5월 31일
此邮件使用英语,旨在为您提供最快速的答复。如果您希望得到中文回复,请告诉我
们。我们同事会为您翻译此邮件。
You can use any (isnan (a11)) or (any (isinf (a11)) to make sure there are no inf or nan values in your array.
Kindly read about them here
  댓글 수: 1
艳荣
艳荣 2023년 9월 25일
I've solved this issue, thanks anyway!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 数值类型에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!