フィルターのクリア

MuPAD error

2 ビュー (過去 30 日間)
Alex
Alex 2012 年 4 月 4 日
Hey all,
I've been debugging this code for a while now, but I can't for the life of my find out what's wrong with this. Whenever I run into a MuPAD error, Mybest solution is usually to come here, so I'm here again? Can someone look through this code and help me out a bit? More eyes are always better, and I'd love to learn more about fixing MuPAD errors. Here's the code:
data = csvread('data.csv');
assert (mod(size(data, 1), 1) == 0, ...
'Input data must have an integer multiple of 1 rows');
assert (size(data, 2) == 8, ...
'Input data must have exactly eight columns.');
syms d1;
nsys = size(data, 1);
for k = 1 : nsys,
F = solve_d_two_layers_eq(data((k-1) + (1:1), 1:end));
d(k, :) = solve(F);
end
dd = double(d);
fid=fopen('d_values.csv','w');
fprintf(fid,'%+5.5f, %+5.5fi\n',[real(dd(:)), imag(dd(:))].');
fclose(fid);
And the function file:
function F = solve_d_two_layers_eq(p)
assert (ndims(p) ==2, ...
'System parameters ''p'' must be 2D matrix.');
assert (all(size(p) ==[1,8]), ...
'System parameters must be 1-by-8 matrix.');
syms d1
n0 = 1;
y = p(:,1);
R = p(:,2);
n1 = p(:,3);
k1 = p(:,4);
n2 = p(:,5);
k2 = p(:,6);
n3 = p(:,7);
k3 = p(:,8);
d2 = 300;
g1 = (n0.^2 - n1.^2 - k1.^2)./((n1 + n2).^2 + k1.^2);
g2 = (n1.^2 - n2.^2 + k1.^2 - k2.^2)./((n1 + n2).^2 + (k1 + k2).^2);
h1 = (2.*n0.*k1)./((n0 + n1).^2 + k1.^2);
h2 = (2.*(n1.*k2 - n2.*k1))./((n1 + n2).^2 + (k1 + k2).^2);
a1 = (2.*pi().*k1.*d1)./y;
b1 = (2.*pi().*n1.*d1)./y;
p2 = (exp(a1)).*cos(b1);
q2 = (exp(a1)).*sin(b1);
t2 = (exp(-1.*a1)).*(g2.*(cos(b1)) + h2.*(sin(b1)));
u2 = (exp(-1.*a1)).*(h2.*(cos(b1)) - g2.*(sin(b1)));
p12 = p2 + g1.*t2 - h1.*u2;
q12 = q2 + h1.*t2 + g1.*u2;
t12 = t2 + g1.*p2 - h1.*q2;
u12 = u2 + h1.*p2 + g1.*q2;
g3 = (n2.^2 - n3.^2 + k2.^2 - k3.^2)./((n2 + n3).^2 + (k2 + k3).^2);
h3 = (2.*(n2.*k3 - n3.*k2))./((n2 + n3).^2 + (k2 + k3).^2);
a2 = (2.*pi().*k2.*d2)./y;
b2 = (2.*pi().*n2.*d2)./y;
p3 = (exp(a2)).*(cos(b2));
q3 = (exp(a2)).*(sin(b2));
t3 = (exp(-1.*a2)).*(g3.*(cos(b2)) + h3.*(sin(b2)));
u3 = (exp(-1.*a2)).*(h3.*(cos(b2)) - g3.*(sin(b2)));
r2 = (exp(a1)).*(g2.*(cos(b1)) - h2.*(sin(b1)));
s2 = (exp(a1)).*(h2.*(cos(b1)) + g2.*(sin(b1)));
v2 = (exp(-1.*a1)).*(cos(b1));
w2 = (-1.*(exp(-1.*a1))).*(sin(b1));
r12 = r2 + g1.*v2 - h1.*w2;
s12 = s2 + h1.*v2 + g1.*w2;
v12 = v2 + g1.*r2 - h1.*s2;
w12 = w2 + h1.*r2 + g1.*s2;
p13 = p12.*p3 - q12.*q3 + r12.*t3 - s12.*u3;
q13 = q12.*p3 + p12.*q3 + s12.*t3 + r12.*u3;
t13 = t12.*p3 - u12.*q3 + v12.*t3 - w12.*u3;
u13 = u12.*p3 + t12.*q3 + w12.*t3 + v12.*u3;
F = (t13.^2 + u13.^2)./(p13.^2 + q13.^2) - R;
  1 件のコメント
Alexander
Alexander 2012 年 4 月 5 日
What error message do you get?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MuPAD についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by