| 查看: 3736 | 回復(fù): 10 | |||
Gout金蟲 (正式寫手)
|
[求助]
如何將取向矩陣中歸一化的{hkl}轉(zhuǎn)化成互質(zhì)化的{HKL},求算法!。!
|
||
|
如何將取向矩陣中歸一化的{hkl}轉(zhuǎn)化成互質(zhì)化的整數(shù){HKL},求程序算法。。。 具體就是將如何將三個(gè)小數(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接近零的同時(shí)k1也接近零 K=0; if sign(l)<0 L=-round(l); else L=round(l); end elseif l1<=1e-3 % h1接近零的同時(shí),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接近零的同時(shí)h1也接近零 H=0; if sign(l)<0 L=-round(l); else L=round(l); end elseif l1<=1e-3 % k1接近零的同時(shí),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接近零的同時(shí)h1也接近零 H=0; if sign(k)<0 K=-round(k); else K=round(k); end elseif k1<=1e-3 % l1接近零的同時(shí),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ā)表 | |
|---|---|---|---|---|
|
[考研] 312求調(diào)劑 +6 | 陌宸希 2026-03-16 | 7/350 |
|
|---|---|---|---|---|
|
[考研] 化學(xué)工程321分求調(diào)劑 +13 | 大米飯! 2026-03-15 | 16/800 |
|
|
[考研] 301求調(diào)劑 +9 | yy要上岸呀 2026-03-17 | 9/450 |
|
|
[考研] 一志愿天津大學(xué)化學(xué)工藝專業(yè)(081702)315分求調(diào)劑 +7 | yangfz 2026-03-17 | 7/350 |
|
|
[考研] [導(dǎo)師推薦]西南科技大學(xué)國(guó)防/材料導(dǎo)師推薦 +3 | 尖角小荷 2026-03-16 | 6/300 |
|
|
[考研] 311求調(diào)劑 +5 | 26研0 2026-03-15 | 5/250 |
|
|
[考研] 070303 總分349求調(diào)劑 +3 | LJY9966 2026-03-15 | 5/250 |
|
|
[考研] 0856求調(diào)劑 +3 | 劉夢(mèng)微 2026-03-15 | 3/150 |
|
|
[考研] 326求調(diào)劑 +3 | mlpqaz03 2026-03-15 | 3/150 |
|
|
[考研] 327求調(diào)劑 +6 | 拾光任染 2026-03-15 | 11/550 |
|
|
[考研] 材料與化工 323 英一+數(shù)二+物化,一志愿:哈工大 本人本科雙一流 +4 | 自由的_飛翔 2026-03-13 | 5/250 |
|
|
[考研] 材料080500調(diào)劑求收留 +3 | 一顆meteor 2026-03-13 | 3/150 |
|
|
[考研] 0703化學(xué)一志愿211 總分320求調(diào)劑 +5 | 瑪卡巴卡啊哈 2026-03-11 | 5/250 |
|
|
[考研] (081700)化學(xué)工程與技術(shù)-298分求調(diào)劑 +12 | 11啦啦啦 2026-03-11 | 35/1750 |
|
|
[考研] 310求調(diào)劑 +3 | 【上上簽】 2026-03-11 | 3/150 |
|
|
[考研] 307求調(diào)劑 +5 | 超級(jí)伊昂大王 2026-03-12 | 5/250 |
|
|
[考研] 274求調(diào)劑 +3 | S.H1 2026-03-12 | 3/150 |
|
|
[考博] 26讀博 +4 | Rui135246 2026-03-12 | 10/500 |
|
|
[考研] 081200-11408-276學(xué)碩求調(diào)劑 +3 | 崔wj 2026-03-12 | 4/200 |
|
|
[考博] 2026年博士申請(qǐng) +3 | QwQwQW10 2026-03-11 | 3/150 |
|