solve求解方程,如何去掉不存在的根。
Show older comments
<div>d=0.01;%m
</div>sum_freq=3000;%Hz
freq_step=100;
freq=1000:freq_step:sum_freq;
fd=freq.*d;
omiga=(2.*pi.*freq)';
ct1=2260;
ct2=3251;
u1=4.55e10;
u2=8.29e10;
rho1=8.9e3;
rho2=7.84e3;
wd=(omiga.*d);
[m n]=size(wd);
aa=u2./u1;
for i=1:length(wd)
cp=sym('cp');
cp=double(solve(tan((wd(i)./cp).*(sqrt((cp./ct1).^2-1)))-(u2./u1).*(sqrt((1-(cp./ct2).^2)./((cp./ct1).^2-1)))==0))
% cp= strrep(cp',[], nan)
cp_new(i)=cp;
end
各位大佬,我在用solve求解上述方程时,遇到当i=18时,会出现错误: Empty matrix: 0-by-1,但是i=1:17是可以得到解的,我想问下,怎么能在程序中设置,当出现这种错误的时候,就把这个解设置为nan,因为我后续还要用cp画图,cp的对应位置与另一个参数的对应位置需要一致,请各位大神帮忙
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!