寫Matlab程式遇到一些問題

我在寫程式中,遇到幾段我實在想不通,或著找不出答案的地方,請各位先進和大大們給予指導

1.有一部分,是要寫我有個2x2的像素區塊;假設左上角是b1,右上角是b2,左下角是b3,右下角是b4
我要計算每個像素對的差值d;d1=b1-b2ˋd2=b1-b3ˋd3=b1-b4

我朋友原本事和我這樣說
for k=1:3
d(k)=abs(b(k)-b(k+1));

不過我發現有錯誤;且那樣寫不知道為什麼,也不是變成d1=abs(b1-b2)是整個想法都有錯??


2.<!–[if !mso]>

v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);}

<![endif]–><!–[if gte mso 9]><>
<w:word>
<w:view>Normal</w:view>
<w:zoom>0</w:zoom>
<w:trackmoves/>
<w:trackatting/>
<w:punctuationkerning/>
<w:displayhorizontaldrawinggridevery>0</w:displayhorizontaldrawinggridevery>
<w:displayverticaldrawinggridevery>2</w:displayverticaldrawinggridevery>
<w:validateagainstschemas/>
<w:saveifinvalid>false</w:saveifinvalid>
<w:ignoremixedcontent>false</w:ignoremixedcontent>
<w:alwaysshowplaceholdertext>false</w:alwaysshowplaceholdertext>
<w:donotpromoteqf/>
<w:lidthemeother>EN-US</w:lidthemeother>
<w:lidthemeasian>ZH-TW</w:lidthemeasian>
<w:lidthemecomplex>X-NONE</w:lidthemecomplex>
<w:compatibility>
<w:spaceforul/>
<w:balancesinglebytedoublebytewidth/>
<w:donotleavebackslashalone/>
<w:ultrailspace/>
<w:donotexpandshiftreturn/>
<w:adjustlineheightintable/>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:splitpgbreakandark/>
<w:dontvertaligncellwithsp/>
<w:dontbreakconstrainedforcedtables/>
<w:dontvertalignintxbx/>
<w:word11kerningpairs/>
<w:cachedcolbalance/>
<w:usefelayout/>
</w:compatibility>
<m:mathpr>
<m:mathfont m:val=“cambria math”/>
<m:brkbin m:val=“before”/>
<m:brkbinsub m:val="–"/>
<m:smallfrac m:val=“off”/>
<m:dispdef/>
<m:lmargin m:val=“0”/>
<m:rmargin m:val=“0”/>
<m:defjc m:val=“centergroup”/>
<m:wrapindent m:val=“1440”/>
<m:intlim m:val=“subsup”/>
<m:narylim m:val=“undovr”/>
</m:mathpr></w:word>
</><![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:表格內文; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;}

<![endif]–>有一段,需要將上面計算出來的結果,分配到兩個相鄰的像素上,成為新的像素對;而且原本上面計算出來有三種結果,所以下面的判斷式,必須分別各做一次,並把結果存起來給更下面計算用,

原公式如下
<!–[if !mso]>

v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);}

<![endif]–><!–[if gte mso 9]><>
<w:word>
<w:view>Normal</w:view>
<w:zoom>0</w:zoom>
<w:trackmoves/>
<w:trackatting/>
<w:punctuationkerning/>
<w:displayhorizontaldrawinggridevery>0</w:displayhorizontaldrawinggridevery>
<w:displayverticaldrawinggridevery>2</w:displayverticaldrawinggridevery>
<w:validateagainstschemas/>
<w:saveifinvalid>false</w:saveifinvalid>
<w:ignoremixedcontent>false</w:ignoremixedcontent>
<w:alwaysshowplaceholdertext>false</w:alwaysshowplaceholdertext>
<w:donotpromoteqf/>
<w:lidthemeother>EN-US</w:lidthemeother>
<w:lidthemeasian>ZH-TW</w:lidthemeasian>
<w:lidthemecomplex>X-NONE</w:lidthemecomplex>
<w:compatibility>
<w:spaceforul/>
<w:balancesinglebytedoublebytewidth/>
<w:donotleavebackslashalone/>
<w:ultrailspace/>
<w:donotexpandshiftreturn/>
<w:adjustlineheightintable/>
<w:breakwrappedtables/>
<w:snaptogridincell/>
<w:wraptextwithpunct/>
<w:useasianbreakrules/>
<w:dontgrowautofit/>
<w:splitpgbreakandark/>
<w:dontvertaligncellwithsp/>
<w:dontbreakconstrainedforcedtables/>
<w:dontvertalignintxbx/>
<w:word11kerningpairs/>
<w:cachedcolbalance/>
<w:usefelayout/>
</w:compatibility>
<m:mathpr>
<m:mathfont m:val=“cambria math”/>
<m:brkbin m:val=“before”/>
<m:brkbinsub m:val="–"/>
<m:smallfrac m:val=“off”/>
<m:dispdef/>
<m:lmargin m:val=“0”/>
<m:rmargin m:val=“0”/>
<m:defjc m:val=“centergroup”/>
<m:wrapindent m:val=“1440”/>
<m:intlim m:val=“subsup”/>
<m:narylim m:val=“undovr”/>
</m:mathpr></w:word>
</><![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:表格內文; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;}

<![endif]–>



PS:還有公式裡面的取上限和取下限,我也不知道要怎麼寫


3.MSE這部分要怎麼寫?