Subscripted assignment dimension mismatch after integration

10 ビュー (過去 30 日間)
Jay
Jay 2017 年 9 月 18 日
コメント済み: Jay 2017 年 9 月 19 日
The following is the code I used -
q=10e8:(20e9-10e8)/1000:20e9;
q=q';
s=length(q);
epso = 8.8 *10.^-12;
epsr=5.7;
ro=3.63*(10.^-3);
epsl = 2.5;
ri=1.13*(10.^-3);
copen = (epso/sqrt(epsr)*log(ro/ri));
cload= (epsl/sqrt(epsr)*log(ro/ri));
t = zeros(1,s);
for f = 1:length(q)
fun = @(x)((((((besselj(0,(2*pi*q(f))/(3e8))*x*ro)-besselj(0,(2*pi*q(f))/(3e8))*x*ri)).^2)./x)*freload(x,q));
y(f) = copen*abs(integral(fun,0,Inf,'Arrayvalued',true));
t(f)=(1-y(f))/(1+y(f));
end
plot (q,t);
where the function freload is as follows -
function f = freload(x,q)
epsl=3.4-0.001j;
f=(1./sqrt(epsl-(x.^2))).*(1+exp(-2*1i*2*pi*q./(3e8).*sqrt(epsl-(x.^2))))./((1-exp(-2*1i*2*pi*q/(3e8).*sqrt(epsl-(x.^2)))));
end
The error i get is as follows - Subscripted assignment dimension mismatch.
Error in numint (line 14) y(f) = copen*abs(integral(fun,0,Inf,'arrayvalued',true));
Any help or suggestion would be greatly appreciated. Thanks

採用された回答

KSSV
KSSV 2017 年 9 月 18 日
YOu have to initialize your t and y as cells.....the output of the line which throws error is a vector, and you are storing it as a scalar...so error popping out.
q=10e8:(20e9-10e8)/1000:20e9;
q=q';
s=length(q);
epso = 8.8 *10.^-12;
epsr=5.7;
ro=3.63*(10.^-3);
epsl = 2.5;
ri=1.13*(10.^-3);
copen = (epso/sqrt(epsr)*log(ro/ri));
cload= (epsl/sqrt(epsr)*log(ro/ri));
t = zeros(1,s);
y = cell(length(q),1) ;
t = cell(length(q),1) ;
for f = 1:length(q)
fun = @(x)((((((besselj(0,(2*pi*q(f))/(3e8))*x*ro)-besselj(0,(2*pi*q(f))/(3e8))*x*ri)).^2)./x)*freload(x,q));
y{f} = copen*abs(integral(fun,0,Inf,'Arrayvalued',true));
t{f}=(1-y{f})./(1+y{f});
end
Now y and t are cells...you can do what you want with them.
  1 件のコメント
Jay
Jay 2017 年 9 月 19 日
Thanks for taking the time to answer my question. But now t is a cell. I intended to plot t as a function of q. Now, I am unable to do so. Is there any way to overcome this ? I know I could extract the data, but I wanted the range of values for t.
Thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by