"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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 31 Mär. 2018
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 Kommentare
Walter Roberson
am 31 Mär. 2018
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.
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!