"Inner matrix dimensions must agree." i need to multiply two matrices but when i try to multiply them i gave that error, when i try element-wise multiplication i gave no error and also i have to see 804 elements for both layer_a,layer_b.but i see 201
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to create a function that has four elements and is square matrice. I also want to create another one which has 4 elements and is square matrice. Then i'll combine this bunch of matrices and finally get overall transfer matrices.
Do you have suggestion about it? im new on matlab. here is my code. entity portion is an issue.
function [m11_a,m12_a,m21_a,m22_a] = layer_a(delta_za,f);
delta_za=450e-9;
N_a=2.5;
f=3e14:1e12:5e14;
w=2*pi*f;
k=N_a*(w/3e8);
q_a=-k/(2*pi*f*4*pi*10e-7);
m11_a=cos(k*delta_za);m12_a=(i/q_a)*sin(k*delta_za);
m21_a=(i*q_a)*sin(k*delta_za);;m22_a=cos(k*delta_za);
end
function [m11_b,m12_b,m21_b,m22_b] = layer_b(delta_zb,f);
delta_zb=400e-9;
N_b=1.5;
f=3e14:1e12:5e14;
w=2*pi*f;
k=N_b*(w/3e8);
q_b=-k/(2*pi*f*4*pi*10e-7);
m11_b=cos(k*delta_zb);m12_b=(i/q_b)*sin(k*delta_zb);
m22_b=(i*q_b)*sin(k*delta_zb);;m22_b=cos(k*delta_zb);
end
%top_entity part
[m11_a,m12_a,m21_a,m22_a] = layer_a();
matrice_a=[m11_a m12_a;m21_a m22_a];
[m11_b,m12_b,m21_b,m22_b] = layer_b();
matrice_b=[m11_b m12_b;m21_b m22_b];
thanks..
댓글 수: 0
답변 (1개)
Walter Roberson
2018년 3월 31일
You have
m2_b=(i*q_b)*sin(k*delta_zb);;m22_b=cos(k*delta_zb);
which is not an assignment to m21_b
댓글 수: 4
Walter Roberson
2018년 3월 31일
Transfer matrices appear to be typically square matrices except possibly for the last of them. You would typically use algebraic matrix multiplication with them, the * operator, instead of the element-by-element multiplication.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!