| 查看: 3739 | 回復(fù): 10 | |||
Gout金蟲 (正式寫手)
|
[求助]
如何將取向矩陣中歸一化的{hkl}轉(zhuǎn)化成互質(zhì)化的{HKL},求算法。。。
|
||
|
如何將取向矩陣中歸一化的{hkl}轉(zhuǎn)化成互質(zhì)化的整數(shù){HKL},求程序算法!。! 具體就是將如何將三個小數(shù)化為互質(zhì)化的整數(shù)?? |
科研、投稿中可能遇到的小問題 |

|
clear clc Indices=input('Please input the normalized indices [hkl]='); h=Indices(1,1)/sqrt(dot(Indices,Indices)); k=Indices(1,2)/sqrt(dot(Indices,Indices)); l=Indices(1,3)/sqrt(dot(Indices,Indices)); h1=abs(h); k1=abs(k); l1=abs(l); if h1>1e-3 && k1>1e-3 && l1>1e-3 % [hkl]均非負(fù) if h1>=l1 && k1>=l1 % l1最小 A=h1/l1; B=k1/l1; i=1; while (abs(A-round(A))>1e-2 || abs(B-round(B))>1e-2) A=A*(i+1)/i; B=B*(i+1)/i; i=i+1; end if sign(l)<0 L=-i; else L=i; end if sign(h)<0 H=-round(A); else H=round(A); end if sign(k)<0 K=-round(B); else K=round(B); end elseif h1>=k1 && l1>=k1 % k1最小 A=h1/k1; B=l1/k1; i=1; while (abs(A-round(A))>1e-2 || abs(B-round(B))>1e-2) A=A*(i+1)/i; B=B*(i+1)/i; i=i+1; end if sign(k)<0 K=-i; else K=i; end if sign(h)<0 H=-round(A); else H=round(A); end if sign(l)<0 L=-round(B); else L=round(B); end elseif k1>=h1 && l1>=h1 % h1最小 A=k1/h1; B=l1/h1; i=1; while (abs(A-round(A))>1e-2 || abs(B-round(B))>1e-2) A=A*(i+1)/i; B=B*(i+1)/i; i=i+1; end if sign(h)<0 H=-i; else H=i; end if sign(k)<0 K=-round(A); else K=round(A); end if sign(l)<0 L=-round(B); else L=round(B); end end elseif h1<=1e-3 % h1 接近零 H=0; if k1<=1e-3 % h1接近零的同時k1也接近零 K=0; if sign(l)<0 L=-round(l); else L=round(l); end elseif l1<=1e-3 % h1接近零的同時,l1也接近零 L=0; if sign(k)<0 K=-round(k); else K=round(k); end elseif k1>1e-3 && l1>1e-3 % 只有h1 接近零 if k1>l1 A=k1/l1; i=1; while(abs(A-round(A))>1e-3) A=A*(i+1)/i; i=i+1; end if sign(l)<0 L=-i; else L=i; end if sign(k)<0 K=-round(A); else K=round(A); end else A=l1/k1; i=1; while(abs(A-round(A))>1e-3) A=A*(i+1)/i; i=i+1; end if sign(k)<0 K=-i; else K=i; end if sign(l)<0 L=-round(A); else L=round(A); end end end elseif k1<=1e-3 % k1 接近零 K=0; if h1<=1e-3 % k1接近零的同時h1也接近零 H=0; if sign(l)<0 L=-round(l); else L=round(l); end elseif l1<=1e-3 % k1接近零的同時,l1也接近零 L=0; if sign(h)<0 H=-round(h); else H=round(h); end elseif h1>1e-3 && l1>1e-3 % 只有k1 接近零 if h1>l1 A=h1/l1; i=1; while(abs(A-round(A))>1e-3) A=A*(i+1)/i; i=i+1; end if sign(l)<0 L=-i; else L=i; end if sign(h)<0 H=-round(A); else H=round(A); end else A=l1/k1; i=1; while(abs(A-round(A))>1e-3) A=A*(i+1)/i; i=i+1; end if sign(h)<0 H=-i; else H=i; end if sign(l)<0 L=-round(A); else L=round(A); end end end elseif l1<=1e-3 % l1 接近零 L=0; if h1<=1e-3 % l1接近零的同時h1也接近零 H=0; if sign(k)<0 K=-round(k); else K=round(k); end elseif k1<=1e-3 % l1接近零的同時,k1也接近零 K=0; if sign(h)<0 H=-round(h); else H=round(h); end elseif h1>1e-3 && k1>1e-3 % 只有l(wèi)1 接近零 if h1>k1 A=h1/k1; i=1; while(abs(A-round(A))>1e-3) A=A*(i+1)/i; i=i+1; end if sign(k)<0 K=-i; else K=i; end if sign(h)<0 H=-round(A); else H=round(A); end else A=k1/h1; i=1; while(abs(A-round(A))>1e-3) A=A*(i+1)/i; i=i+1; end if sign(h)<0 H=-i; else H=i; end if sign(k)<0 K=-round(A); else K=round(A); end end end end disp('互質(zhì)化后的指數(shù)[HKL]=') disp([H K L]) |
金蟲 (著名寫手)


金蟲 (正式寫手)

金蟲 (正式寫手)

金蟲 (正式寫手)

鐵蟲 (小有名氣)

銅蟲 (小有名氣)
|
Textools有試用版的。http://www.sciencesoftware.com.c ... detail12.asp?id=688 在右側(cè)那邊可以下載試用版 |
新蟲 (初入文壇)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 274求調(diào)劑 +5 | S.H1 2026-03-18 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 295求調(diào)劑 +3 | 一志愿京區(qū)211 2026-03-18 | 5/250 |
|
|
[考研] 化學(xué)工程321分求調(diào)劑 +15 | 大米飯! 2026-03-15 | 18/900 |
|
|
[考研] 331求調(diào)劑(0703有機(jī)化學(xué) +7 | ZY-05 2026-03-13 | 8/400 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機(jī)?/a> 2026-03-16 | 3/150 |
|
|
[考研] 268求調(diào)劑 +7 | 好運(yùn)連綿不絕 2026-03-12 | 8/400 |
|
|
[考研] 材料與化工求調(diào)劑 +6 | 為學(xué)666 2026-03-16 | 6/300 |
|
|
[考研] 材料工程專碩調(diào)劑 +5 | 204818@lcx 2026-03-17 | 5/250 |
|
|
[考研] 考研化學(xué)學(xué)碩調(diào)劑,一志愿985 +4 | 張vvvv 2026-03-15 | 6/300 |
|
|
[考研] 材料與化工專碩調(diào)劑 +5 | heming3743 2026-03-16 | 5/250 |
|
|
[考博] 26申博 +4 | 八旬速覽 2026-03-16 | 4/200 |
|
|
[考研] 材料工程專碩274一志愿211求調(diào)劑 +6 | 薛云鵬 2026-03-15 | 6/300 |
|
|
[考研] 275求調(diào)劑 +4 | 太陽花天天開心 2026-03-16 | 4/200 |
|
|
[考研]
|
zhouzhen654 2026-03-16 | 3/150 |
|
|
[基金申請] 國自科面上基金字體 +6 | iwuli 2026-03-12 | 7/350 |
|
|
[考研] 304求調(diào)劑 +3 | 曼殊2266 2026-03-14 | 3/150 |
|
|
[考研]
|
笨笨兔子 2026-03-12 | 3/150 |
|
|
[考研] 中科大材料與化工319求調(diào)劑 +3 | 孟鑫材料 2026-03-14 | 3/150 |
|
|
[考研] 330求調(diào)劑 +3 | ?醬給調(diào)劑跪了 2026-03-13 | 3/150 |
|
|
[考研] 308求調(diào)劑 +3 | 是Lupa啊 2026-03-12 | 3/150 |
|