Ungayifaka njani iiVectors kunye neMatriki kwiMATLAB

NguJim Sizemore, uJohn Paul Mueller

Cinga ngendlela oyisebenzisa ngayo idatha xa usebenza ngezibalo: Idatha ibonakala njengoluhlu lwamanani okanye isicatshulwa. IMATLAB isebenzisa umbono ofanayo. Ikwasebenza ngoluhlu lwamanani kunye nesicatshulwa osenzayo ngeendlela ezahlukeneyo.

Ukungenisa amaxabiso ngaphakathi kwizibiyeli ezisikwere

Isibiyeli esisekwe ngasekhohlo,[, uqala uluhlu lwamanani okanye isicatshulwa. Isibiyeli esisekunene,], iphelisa uluhlu. Ungeniso ngalunye kuluhlu lwahlulwe yikoma (,). Ukuzama obu buchule ngokwakho, vula iMATLAB, chwetheza b = [5, 6] kwiWindows Command, kwaye ucinezele u-Enter. Uyabona

b = 5 6

Ulwazi lugcinwa njengoluhlu lwamanani amabini. Inani ngalinye liphathwa njengexabiso elahlukileyo. Cofa kabinibKwiwindow yeSithuba sokuSebenza kwaye ubona amangeniso amabini ahlukeneyo. Qaphela ukuba iwindow yendawo yokusebenzela ibonisabnjengoluhlu lwe-1 x 2 apho amangeno ahamba ngokuthe tye.

umfanekiso0.jpg

Ungachwetheza ifomati kwaye ucinezela u-Enter ukugcina indawo yokubonisa. Ukuba ufuna ukucoca indawo kwiWindows Command ngokuchwetheza imiyalelo eyongezelelweyo, chwetheza clc kwaye ucinezela u-Enter.

Ukuqala umgca omtsha okanye umqolo nge semicolon

Ikoma idala amangeniso ahlukeneyo kumqolo omnye. Usebenzisa isemicolon (;) ukuvelisa imiqolo emitsha. Ukuzama obu buchule ngokwakho, chwetheza e = [5; [Umfanekiso okwiphepha 6] kwiWindows Command kwaye ucofe u-Enter. Uyabona

e = 5 6

Ulwazi lugcinwa njengoluhlu lwamanani amabini. Nangona kunjalo, ulungelelwaniso lwamanani lwahlukile. Cofa kabininguKwiwindow yeSithuba sokuSebenza kwaye ubona amangeniso amabini ahlukeneyo. Qaphela ukuba iwindow yendawo yokusebenzela ibonisangunjengoluhlu olungu-2 x 1 apho amangeno ahamba ngokuthe nkqo.

umfanekiso1.jpg

Ukwahlula amaxabiso ngekoma okanye isemicolon

Kuyenzeka ukuba wenze i-matrix ngokudibanisa ii-commas kunye ne-semicolons. Iikhoma zahlula amangeno kumqolo omnye kunye neesemikholoni zenza imiqolo emitsha. Ukuzibonela oku ngokwakho, chwetheza a = [1, 2; 3. 4] kwiWindows Command kwaye ucofe u-Enter. Uyabona

a = 1 2 3 4

Ukufumana ubungakanani beematriki ngekholamu yesayizi

Kukho indlela elula yokufumana ubungakanani boluhlu lwamanani indlela elula. Cofa ekunene Uluhlu lwekholamu yendawo yokuSebenza kwaye ukhethe ubungakanani kwimenyu yokuma.

Unokufumana ukuba luncedo ukubonisa ubuncinci kunye namaxabiso aphezulu kungeniso ngalunye. Olu lwazi luza luncedo xa usebenza nezilwanyana ezinkulu okanye imatriki apho ubuncinci kunye namaxabiso aphezulu angabonakali. Ukufumana olu lwazi, khetha iikholamu → iMin, uze ukhethe iikholamu → Ubukhulu.

umfanekiso2.jpg

Ukwenza uluhlu lwamaxabiso usebenzisa ikholoni

Ukuchwetheza ixabiso ngalinye kuluhlu ngesandla kungatya ixesha kunye neempazamo kuba uya kuthi udikwe kukwenza. Ngethamsanqa, ungasebenzisa ikholoni (:ukufaka uluhlu lwamanani kwi-MATLAB. Inani kwicala lasekhohlo lekholoni lichaza ukuqala koluhlu, kwaye inani elisekunene lekholoni lichaza ukuphela koluhlu.

Ukuzibonela oku ngokwakho, chwetheza g = [5:10] kwaye ucinezela u-Enter. Uyabona

g = 5 6 7 8 9 10

Ukwenza uluhlu lwamaxabiso usebenzisa i-linspace ()

Sebenzisa ikholoni ukwenza uluhlu lunengxaki. IMATLAB ithatha ukuba inyathelo ngu-1. Nangona kunjalo, ungafuna amanani ahlukaniswe lelinye ixabiso. Umzekelo, unokufuna ukubona amaxabiso ali-11 phakathi koluhlu lwe-5 kunye ne-10, endaweni ye-6 kuphela.

Inkqubo ye-isithuba ()Umsebenzi usombulula le ngxaki. Unikezela ngexabiso lokuqala, ixabiso lokugqibela, kunye nenani lamaxabiso ofuna ukuwabona phakathi kwexabiso lokuqala nelokuphela. Ukubona njaniisithuba ()works, chwetheza g = indawo yokuphumla (5,10,11) kwaye ucinezela u-Enter. Uyabona

g = Columns 1 through 5 5.0000 5.5000 6.0000 6.5000 7.0000 Columns 6 through 10 7.5000 8.0000 8.5000 9.0000 9.5000 Column 11 10.0000

Kule meko, ixabiso lesinyathelo ngu-0.5. Inani ngalinye liphezulu nge-0.5 kunelo lokugqibela, kwaye kukho amaxabiso ali-11 kwimveliso. Uluhlu luqala ku-5 ukuya ku-10. Ngokufutshane, usebenzisaisithuba ()iguquguquka kancinci kunokusebenzisa ikholoni, kodwa ukusebenzisa ikholoni kufuna ukuthayipha okuncinci kwaye kulula ukukhumbula.

Ukongeza inyathelo kwindlela yekholoni

Kuya kuvela ukuba ungakhankanya inyathelo xa usebenzisa indlela yekolon. Nangona kunjalo, kule meko wongeza inyathelo phakathi kokuqala nokuphela kwoluhlu xa uchaza uluhlu. Ke, uchwetheza inani lokuqala, inyathelo, kunye nenombolo yokuphela, zonke zahlulwe ziikholoni. Ukuzama le ndlela ngokwakho, chwetheza g = [5: 0.5: 10] kwaye ucinezela u-Enter. Uyabona

g = Columns 1 through 5 5.0000 5.5000 6.0000 6.5000 7.0000 Columns 6 through 10 7.5000 8.0000 8.5000 9.0000 9.5000 Column 11 10.0000

Esi sisiphumo esifanayo ngokuchanekileyo neso seisithuba ()umzekelo. Nangona kunjalo, xa usebenzisa le ndlela, uchaza inyathelo ngokuthe ngqo, ukuze ungalawuli inani lamaxabiso owafumanayo njengemveliso. Xa usebenzisa iisithuba ()indlela, ucacisa inani lamaxabiso owafumanayo njengokuphuma kwawo, kodwa iMATLAB ilibala ixabiso lesinyathelo sakho.

Ukutshintsha imatriki ngesimelabizo

Sebenzisa ikholoni kudala umgca weevec. Nangona kunjalo, ngamanye amaxesha ufuna ikholam vector endaweni yoko. Ukwenza i-vector yekholamu, ugqiba igalelo ngesimelabizo. Ukubona ukuba isebenza njani le nto kuwe, chwetheza h = [5: 0.5: 10] ’ kwaye ucinezela u-Enter. Uyabona

h = 5.0000 5.5000 6.0000 6.5000 7.0000 7.5000 8.0000 8.5000 9.0000 9.5000 10.0000

Xa ujonga indawo yokusebenzela, uyayibona loo ntogyi-1 x 11 vector, ngelixahyi-11 x 1 vector. Ingeniso yokuqala ngumqolo wevektha kwaye okwesibini yivektha yekholamu.

Ungadlulisa imatriki ngokunjalo. Imiqolo kunye neekholamu zitshintsha indawo. Umzekelo, ngaphambili uchwethezilea = [1,2,3,4], evelisileyo

a = 1 2 3 4

Ukubona ukuba le matrix ijongeka kanjani idlulisiwe, chwetheza mna = [1,2; 3,4] ’ kwaye ucinezela u-Enter. Uyabona

i = 1 3 2 4