Matlab 第一章习题解答Word文档格式.docx

上传人:b****6 文档编号:21912606 上传时间:2023-02-01 格式:DOCX 页数:42 大小:1.06MB
下载 相关 举报
Matlab 第一章习题解答Word文档格式.docx_第1页
第1页 / 共42页
Matlab 第一章习题解答Word文档格式.docx_第2页
第2页 / 共42页
Matlab 第一章习题解答Word文档格式.docx_第3页
第3页 / 共42页
Matlab 第一章习题解答Word文档格式.docx_第4页
第4页 / 共42页
Matlab 第一章习题解答Word文档格式.docx_第5页
第5页 / 共42页
点击查看更多>>
下载资源
资源描述

Matlab 第一章习题解答Word文档格式.docx

《Matlab 第一章习题解答Word文档格式.docx》由会员分享,可在线阅读,更多相关《Matlab 第一章习题解答Word文档格式.docx(42页珍藏版)》请在冰豆网上搜索。

Matlab 第一章习题解答Word文档格式.docx

Relationaloperators.

eq-Equal==

ne-Notequal~=

lt-Lessthan<

gt-Greaterthan>

le-Lessthanorequal<

=

ge-Greaterthanorequal>

Logicaloperators.

relop-Short-circuitlogicalAND&

&

relop-Short-circuitlogicalOR||

and-Element-wiselogicalAND&

or-Element-wiselogicalOR|

not-LogicalNOT~

xor-LogicalEXCLUSIVEOR

any-Trueifanyelementofvectorisnonzero

all-Trueifallelementsofvectorarenonzero

Specialcharacters.

colon-Colon:

paren-Parenthesesandsubscripting()

paren-Brackets[]

paren-Bracesandsubscripting{}

punct-Functionhandlecreation@

punct-Decimalpoint.

punct-Structurefieldaccess.

punct-Parentdirectory..

punct-Continuation...

punct-Separator,

punct-Semicolon;

punct-Comment%

punct-Invokeoperatingsystemcommand!

punct-Assignment=

punct-Quote'

transpose-Transpose.'

ctranspose-Complexconjugatetranspose'

horzcat-Horizontalconcatenation[,]

vertcat-Verticalconcatenation[;

]

subsasgn-Subscriptedassignment(),{},.

subsref-Subscriptedreference(),{},.

subsindex-Subscriptindex

Bitwiseoperators.

bitand-Bit-wiseAND.

bitcmp-Complementbits.

bitor-Bit-wiseOR.

bitmax-Maximumfloatingpointinteger.

bitxor-Bit-wiseXOR.

bitset-Setbit.

bitget-Getbit.

bitshift-Bit-wiseshift.

Setoperators.

union-Setunion.

unique-Setunique.

intersect-Setintersection.

setdiff-Setdifference.

setxor-Setexclusive-or.

ismember-Trueforsetmember.

Seealsoarith,relop,slash,function_handle.

arith

Arithmeticoperators.

+Plus.

X+YaddsmatricesXandY.XandYmusthavethesame

dimensionsunlessoneisascalar(a1-by-1matrix).

Ascalarcanbeaddedtoanything.

-Minus.

X-YsubtractsmatrixXfromY.XandYmusthavethesame

dimensionsunlessoneisascalar.Ascalarcanbesubtracted

fromanything.

*Matrixmultiplication.

X*YisthematrixproductofXandY.Anyscalar(a1-by-1matrix)

maymultiplyanything.Otherwise,thenumberofcolumnsofXmust

equalthenumberofrowsofY.

.*Arraymultiplication

X.*Ydenoteselement-by-elementmultiplication.XandY

musthavethesamedimensionsunlessoneisascalar.

Ascalarcanbemultipliedintoanything.

^Matrixpower.

Z=X^yisXtotheypowerifyisascalarandXissquare.Ifyisan

integergreaterthanone,thepoweriscomputedbyrepeated

multiplication.Forothervaluesofythecalculation

involveseigenvaluesandeigenvectors.

Z=x^YisxtotheYpower,ifYisasquarematrixandxisascalar,

computedusingeigenvaluesandeigenvectors.

Z=X^Y,wherebothXandYarematrices,isanerror.

.^Arraypower.

Z=X.^Ydenoteselement-by-elementpowers.XandY

musthavethesamedimensionsunlessoneisascalar.

Ascalarcanoperateintoanything.

Relop

Relationaloperators.

<

>

Thesixrelationaloperatorsare<

<

=,>

>

=,==,and~=.

A<

BdoeselementbyelementcomparisonsbetweenAandB

andreturnsamatrixofthesamesizewithelementssettological

1(TRUE)wheretherelationistrueandelementssettological0

(FALSE)whereitisnot.AandBmusthavethesamedimensions

(oronecanbeascalar).

&

Element-wiseLogicalAND.

A&

Bisamatrixwhoseelementsarelogical1(TRUE)wherebothA

andBhavenon-zeroelements,andlogical0(FALSE)whereeitherhas

azeroelement.AandBmusthavethesamedimensions(oronecan

beascalar).

Short-CircuitLogicalAND.

BisascalarvaluethatisthelogicalANDofscalarAandB.

Thisisa"

short-circuit"

operationinthatMATLABevaluatesBonly

iftheresultisnotfullydeterminedbyA.Forexample,ifAequals

0,thentheentireexpressionevaluatestological0(FALSE),regard-

lessofthevalueofB.Underthesecircumstances,thereisnoneed

toevaluateBbecausetheresultisalreadyknown.

|Element-wiseLogicalOR.

A|Bisamatrixwhoseelementsarelogical1(TRUE)whereeither

AorBhasanon-zeroelement,andlogical0(FALSE)wherebothhave

zeroelements.AandBmusthavethesamedimensions(oronecan

||Short-CircuitLogicalOR.

A||BisascalarvaluethatisthelogicalORofscalarAandB.

1,thentheentireexpressionevaluatestological1(TRUE),regard-

lessofthevalueofB.Underthesecircumstances,thereisnoneed

~Logicalcomplement(NOT).

~Aisamatrixwhoseelementsarelogical1(TRUE)whereAhaszero

elements,andlogical0(FALSE)whereAhasnon-zeroelements.

xorExclusiveOR.

xor(A,B)islogical1(TRUE)whereeitherAorB,butnotboth,is

non-zero.SeeXOR.

Slash

Matrixdivision.

\Backslashorleftdivision.

A\BisthematrixdivisionofAintoB,whichisroughlythe

sameasINV(A)*B,exceptitiscomputedinadifferentway.

IfAisanN-by-NmatrixandBisacolumnvectorwithN

components,oramatrixwithseveralsuchcolumns,then

X=A\BisthesolutiontotheequationA*X=Bcomputedby

Gaussianelimination.AwarningmessageisprintedifAis

badlyscaledornearlysingular.A\EYE(SIZE(A))producesthe

inverseofA.

IfAisanM-by-NmatrixwithM<

or>

NandBisacolumn

vectorwithMcomponents,oramatrixwithseveralsuchcolumns,

thenX=A\Bisthesolutionintheleastsquaressensetothe

under-oroverdeterminedsystemofequationsA*X=B.The

effectiverank,K,ofAisdeterminedfromtheQRdecomposition

withpivoting.AsolutionXiscomputedwhichhasatmostK

nonzerocomponentspercolumn.IfK<

Nthiswillusuallynot

bethesamesolutionasPINV(A)*B.A\EYE(SIZE(A))producesa

generalizedinverseofA.

/Slashorrightdivision.

B/AisthematrixdivisionofAintoB,whichisroughlythe

sameasB*INV(A),exceptitiscomputedinadifferentway.

Moreprecisely,B/A=(A'

\B'

)'

.See\.

./Arrayrightdivision.

B./Adenoteselement-by-elementdivision.AandB

Ascalarcanbedividedwithanything.

.\Arrayleftdivision.

A.\B.denoteselement-by-elementdivision.AandB

function_

FUNHANDLE=@FUNCTION_NAMEreturnsahandletothenamedfunction,

FUNCTION_NAME.AfunctionhandleisaMATLABvaluethatprovidesa

meansofcallingafunctionindirectly.Youcanpassfunction

handlesincallstootherfunctions(whichareoftencalledfunction

functions).Youcanalsostorefunctionhandlesindatastructuresfor

lateruse(forexample,asHandleGraphicscallbacks).Afunction

handleisoneofthestandardMATLABdatatypes.Itsclassis

'

function_handle'

.

FUNHANDLE=@(ARGLIST)EXPRESSIONconstructsananonymousfunctionand

returnsahandletothatfunction.Thebodyofthefunction,tothe

rightoftheparentheses,i

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1