I want to make a 2x2 matrix from 4 variables that are dependent on a value(e) that goes from 0 to 30 at intervals of 0.1?

1 回表示 (過去 30 日間)

So I have code with 4 variables that are dependant on a variable e that goes from 0 to 30 at intervals of 0.1. Now i want to make a 2x2 matrix of the 4 variable at every interval of e how do i code that?

e=0:0.1:30;

for i=1:length(e)

    m=9.1*10^-31;
    h=(6.63*10^-34)/(2*pi);
    v=(15*(1.6*10^-19));
    a=1*10^-10;
    b=2*10^-10;
    %igam=sqrt(-1)*sqrt((2*m/h)*((v-(e.*1.6*10^-19))));
    %qalt=sqrt((2*m/h)*((e.*(1.6*10^-19))-v));
    k=sqrt((2*m*(e.*(1.6*10^-19)))/h^2);
    E=e(i);
    if i<=150
        q(i)=sqrt(-1)*sqrt((2*m/h)*((v-(E.*1.6*10^-19))))
    else
        q(i)=sqrt((2*m/h)*((E.*(1.6*10^-19))-v));
    end

end

A11=((k+q)/(2*k))*exp(sqrt(-1)*q*a);

A12=((k-q)/(2*k))*exp(-sqrt(-1)*q*a);

A21=((k-q)/(2*k))*exp(sqrt(-1)*q*a);

A22=((k+q)/(2*k))*exp(-sqrt(-1)*q*a);

B11=((q+k)/(2*q))*exp(sqrt(-1)*k*b);

B12=((q-k)/(2*q))*exp(-sqrt(-1)*k*b);

B21=((q-k)/(2*q))*exp(sqrt(-1)*k*b);

B22=((q+k)/(2*q))*exp(-sqrt(-1)*k*b); % M1= [A11 A12]

M1=[A11 A12 ; A21 A22];

M2=[B11 B12; B21 B22];

This is my code so far. I want M1 and M2 to be 2x2 matrices of the variables i calculated, but I am creating just a single matrix for m1 and m2 that is 2x602

回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by