load ('e1.mat')syms y d=1.8;%input('請輸入芯層厚度:');for i=0:Nq=i;n=teneff1{i+1,1}r1=sqrt(n^2-n1^2)*k0;r2=sqrt(n2^2-n^2)*k0;r3=sqrt(n^2-n3^2)*k0;a=-atan(r3/r2)+q*pi;if y>dEY1=cos(r2*d+a)*exp(-r1*(y-d))else if 0<y<dEY1=cos(r2*y+a);else y<0EY1=cos(a)*exp(r3*y)endendend這個程序是分段函數(shù),運行時d有問題:無法從 sym 轉(zhuǎn)換為 logical。出錯 EYy (line 12)if y>d
問下這個是正負(fù)無窮的函數(shù),分段函數(shù)寫的對嗎?
弒天下
2023-03-20 13:09:57