Creating an arry with vectors as elements

조회 수: 10 (최근 30일)
shan anjum
shan anjum 2016년 10월 12일
답변: KSSV 2016년 10월 13일
Hello Matlab Community!
Im working with a QM modell. I want to create a script that calculates the energy levels for a quantum well. I know what energy eignevalues i have, and i know their degenercy. I want to create a script that fills my system with N particles from the lowest state up, and has the total system energy E as its output.
Im starting to think that i might need to use a cell/strucutre arry instead of an old fashioned matrix. I want to sort my arry and add up the energies, keeping the degenercy in mind.
So far I created a n*n cellstrucutre, and every element is a 1*2 vector. I want to sort this strucure with respect to the first element in my vector. How do i sort my cell? Also how do i acces the diffrent elements in my cellstructure?
  댓글 수: 1
James Tursa
James Tursa 2016년 10월 12일
You've got an nxn matrix, so how do you want it sorted? By columns? Or ...?

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2016년 10월 13일
In = {'Tom' 'Dick' 'Hary'; 12 6 8} ;
% accessing
In{1,1}
In{2,1}
% sorting in descending order
[val, idx] = sort([In{2,:}], 'descend');
In(:,idx)

카테고리

Help CenterFile Exchange에서 Quantum Mechanics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by