Taller 2 de Matlab
September 16, 2022 | Author: Anonymous | Category: N/A
Short Description
Download Taller 2 de Matlab...
Description
%% WEHHD_ ? OTMHD] DF IEWHEO %% DKDIQHC] GDH WEHHD_ %% Icgljlqud dh prcbreie gdh dkdiphc eftdrlcr pere qud gdtdrilfd sl dh fûidrc glbltegc pcr dh usuerlc ds ieycr, lbueh c idfcr e 4. mhm, mhder, mhder ehh ff 9 lfput('Glbltd uf fûidrc; ')0 lj ff 6 4 sprlftj('Dh fûidrc %g ds ieycr qud 4.',ff) dhsdlj ff 8 4 sprlftj('Dh fûidrc %g ds idfcr qud 4.',ff) dhsd sprlftj('Dh fûidrc %g lbueh e 4.',ff) dfg %% Icgljlqud dh prcbreie pere qud lfmhuye hcs mchcrds sdmufgerlcs (eierlhhc, iebdfte, myef) mhm, mhder, mhder ehh ff 9 lfput('Glbltd uf mchcr; ','s')0 swltmn hcwdr(ff) mesd 'rckc' strmet(ff,' ds uf mchcr prlierlc.') dfg
mesd 'ezuh' strmet(ff,' mesd 'vdrgd' strmet(ff,' mesd 'eierlhhc' strmet(ff,' mesd 'iebdfte' strmet(ff,' mesd 'myef' strmet(ff,' ctndrwlsd strmet(ff,'
ds uf mchcr prlierlc.') ds uf mchcr prlierlc.') ds uf mchcr sdmufglerlc.') ds uf mchcr sdmufglerlc.') ds uf mchcr sdmufglerlc.') FC ds uf mchcr prlierlc fl sdmufgerlc.')
%% MLMHC JC_ %% Dkdiphc; Bdfdrer uf vdmtcr mcf hcs prlidrcs f fûidrcs feturehds mhm, mhder, mhder ehh ff 9 lfput('Glbltd uf fûidrc fetureh; ')0 jcr l 9 5;ff iet(5,l) 9 l dfg iet %% Gegc uf fûidrc f mehmuhd he suie gd dhhcs (mciperer mcf dh mciefgc sui(5;f)) mhm, mhder, mhder ehh ff 9 lfput('Glbltd uf fûidrc fetureh; ')0 jcr l 9 5;ff iet(5,l) 9 l dfg x9sui(iet)
%% MLMHC RNLHD - dkdiphc gdh tehhdr. Bdfdrer uf vdmtcr mcf hcs prlidrcs f fûidrcs
feturehds. mhm, mhder, mhder ehh ff 9 lfput('Glbltd uf fûidrc fetureh; ')0 l 9 50 wnlhd l 89 ff iet(5,l) 9 l0 l 9 l+5 0 % Mcftegcr dfg iet %% Gegc uf fûidrc f mehmuhd he suie gd dhhcs (mciperer mcf dh mciefgc sui(5;f)). mhm, mhder, mhder ehh ff 9 lfput('Glbltd uf fûidrc fetureh; ')0 l 9 50 wnlhd l 89 ff iet(5,l) 9 l0 l 9 l+5 0 % Mcftegcr dfg glsp('iudstrd dh vdmtcr') x9sui(iet)
%% DkD_MLMLC] WEHHD_ %% 5. _dehlmd uf ehbcrltic qud crgdfd gd idfcr e ieycr trds fûidrcs lfbrdsegcs pcr dh usuerlc mhm, mhder, mhder ehh E 9 lfput('Glbltd dh prlidr fûidrc; ')0 O 9 lfput('Glbltd dh sdbufgc fûidrc; ')0 M 9 lfput('Glbltd dh tdrmdr fûidrc; ')0 lj E6O & E6M & O6M jprlftj('Hcs vehcrds gd idfcr e ieycr scf; dhsdlj E6O & E6M & M6O jprlftj('Hcs vehcrds gd ieycr e idfcr scf; dhsdlj O6E & O6M & E6M jprlftj('Hcs vehcrds gd ieycr e idfcr scf; dhsdlj O6E & O6M & M6E jprlftj('Hcs vehcrds gd ieycr e idfcr scf; %g, dhsdlj M6E & M6O & E6O jprlftj('Hcs vehcrds gd ieycr e idfcr scf; %g, dhsdlj M6E & M6O & O6E jprlftj('Hcs vehcrds gd ieycr e idfcr scf; %g, dhsd jprlftj('Wcgcs hcs vehcrds scf lbuehds') dfg
%g, %g, %g',M, O, E) %g, %g, %g',O, M, E) %g, %g, %g',M, E, O) %g, %g',E, M, O) %g, %g',O, E, M) %g, %g',E, O, M)
%% ?. Glsdõd dh ehbcrltic gdh prcbreie qud pdrilte rdschvdr he dmuemlýf gd sdbufgc bregc. mhm, mhder, mhder ehh %% =. Dsmrloe uf smrlpt qud dvehud sl dh fûidrc glbltegc pcr dh usuerlc ds pcsltlvc c fdbetlvc. Egdiås gdod icstrer uf idfsekd dspdmljlmåfgchc
mhm, mhder, mhder ehh E 9 lfput('Glbltd dh prlidr fûidrc; ')0 lj E610 jprlftj('Dh fûidrc rdblstregc ds pcsltlvc') dhsdlj E810 jprlftj('Dh fûidrc rdblstregc ds fdbetlvc') dhsd E910 jprlftj('Dh fûidrc rdblstregc ds mdrc') dfg %% 7. Dsmrloe uf ehbcrltic qud hd prdbuftd eh usuerlc mcf mueh tlpc gd merbe quldrd qud sd efehlmd ufe vlbe sliphdidftd epcyege. mhm, mhder, mhder ehh
mnclmd9 idfu('Uud tlpc gd merbe gdsder diphder; ', 'E. Quftueh df dh mdftrc gd he huz', 'O. glstrloulge df dh mdftrc gd he huz')0
%E. Quftueh df dh mdftrc gd he huz lj mnclmd9950 Q9 gd dftrd he merbe PWcfY; ')0 H9 lfput lfput ('Glbltd ('Glbltd vehcr hcfbltug epcycs PiY; ')0 jcr n91;5;H0 l 9 50 wnlhd l 89 (H/?) +5 Z5(5,l) 9 Q/?0 l 9 l+5 0 % Mcftegcr dfg Z50 n591;5;H/?0 suophct (?, 5, 5) phct(n5, Z5, '-r') l 9 50 wnlhd l 89 (H/?)+5 Z?(5,l) 9 Q/?-Q0 l 9 l+5 0 % Mcftegcr dfg Z?0 n?9H/?;5;H0 dfg nchg cf
phct(n?, Z?, '-r') x59Pn5(5,dfg), n?(5,5)Y0 y59PZ5(5,dfg),Z?(5,5)Y0
phct(x5,y5,'-r') xhli(P-5 H+5Y)0 yhli(P(-Q/?)-? (Q/?)+?Y)0 poespdmt(P7 5 5Y)0 jprlftj('_59 %g Wcf Xf',Q*H/? ) jprlftj('_?9 %g Wcf Xf',Q*H/? ) %Hlfdes gd rdjdrdfmle ^59 P1 1Y0 \59 P1 Q/?Y0
phct(^5, \5, '-r') nchg cf ^?9 P1 HY0 \?9 P1 1Y0 phct(^?, \?, '-r') ^=9 PH HY0 \=9 P1 -Q/?Y0 phct(^=, \=, '-r')0 McrteftdIexlie9phct(H/?, Q*H/?,'o*')0 hdbdfg(PMcrteftdIexlieY,{'Mcrteftd Iexlie'})0
tlthd('Glebreie gd mcrteftd') xheodh('(i)') yheodh('(Wcf)') nchg cjj
% Glebreie gd icidftc Ix9P1 H H/? 1Y0 Iy9P1 1 (-Q*H/7) 1Y0 suophct(?, 5, ?) phct(Ix, Iy) xhli(P-5 H+5Y)0 yhli(P(-Q*H/7)-51 (Q*H/7)+51Y)0 poespdmt(P7 5 5Y)0 nchg cf IcidftcIexlic9phct(H/?, (-Q*H/7),'r*')0 hdbdfg(PIcidftcIexlicY,{'Icidftc Iåxlic'})0 Iiex9 -Q*H/70 jprlftj('Iiex9 %g Wcf-i Xf',Iiex ) tlthd('Glebreie gd icidftc') xheodh('(i)') yheodh('(Wcf-i)') nchg cjj % Glebreie gdjhdxlýf
%D9?5>>5 %(Wcf/i?) %L9 %y9-(Q*(HV=))/(7>*D*L)
% O. glstrloulge df dh mdftrc gd he huz dhsdlj mnclmd99?0 Q9 lfput ('Glbltd vehcr gd he merbe glstrloulge PWcf-iY; ')0 H9 lfput ('Glbltd hcfbltug dftrd epcycs PiY; ')0 %Mcrteftd _y9 Q*H/?0 Zmx9P1 1 H/?Y0 Zmy9P1 _y 1Y0 suophct(?, 5, 5) phct(Zmx, Zmy, '-r')0 jprlftj('_y59 %g Wcf Xf',Q*H/? ) jprlftj('_y?9 %g Wcf Xf',Q*H/? ) Zmx9PH/? H HY0 Zmy9P1 -_y 1Y0 nchg cf phct(Zmx, Zmy, '-r') xhli(P-5 H+5Y)0 %exls(P-5 H+5 _y+4 -_y-4Y) %yhli(P:1 :1Y)0%(Q*H/?)+51 poespdmt(P7 5 5Y)0 %Hlfde gd rdjdrdfmle x9P1 HY0 y9P1 1Y0 phct(x, y, '-r') tlthd('Glebreie gd mcrteftd') xheodh('(i)') yheodh('(Wcf)') %Quftc iexlic gd mcrteftd McrteftdIexlie9phct(1, (Q*H/?),'*o')0 hdbdfg(PMcrteftdIexlieY,{'Mcrteftd Iåxlie'})0 nchg cjj % Glebreie gd icidftc l910 jcr l95;5;H0 t(5,l+5)9l0 dfg t0 x910 jcr x95;5;H0 IE9((Q*x)/?)*(H-x)0 Ie(5, x+5)9IE0 dfg
Ie0
suophct(?, 5, ?) phct(t, -Ie) nchg cf poespdmt(P7 5 5Y)0 Iiex9 -(Q*HV?)/>0 jprlftj('Iiex9 %g Wcf-i Xf',Iiex ) IcidftcIexlic9phct(H/?, Iiex,'r*')0 hdbdfg(PIcidftcIexlicY,{'Icidftc Iåxlic'})0 xhli(P-5 H+5Y)0 yhli(PIiex-51 51Y)0 %Hlfde rdjdrdfmle x9P1 HY0 y9P1 1Y0 phct(x, y, '-o') tlthd('Glebreie gd icidftc') xheodh('(i)') yheodh('(Wcf-i)')
dfg
%% 4. Dsmrloe uf ehbcrltic qud hde gdh tdmhegc uf fûidrc dftdrc y qud mciprudod sl ds idfcr qud 4 mhm, mhder, mhder ehh E 9 lfput('Glbltd uf fûidrc; ')0 wnlhd E~94 E 9 lfput('Glbltd uf fûidrc; ')0 dfg jprlftj('Dh fûidrc rdblstregc ds 4') %% :. Qdglr gcs fûidrcs d lfglmer muåh ds dh ieycr gd hcs gcs fûidrcs mcftrchefgc dh mesc gd lbuehds. mhm, mhder, mhder ehh E 9 lfput('Glbltd dh prlidr fûidrc; ')0 O 9 lfput('Glbltd dh sdbufgc fûidrc; ')0 lj E6O jprlftj('Dh fûidrc rdblstregc %g ds ieycr e %g', E, O) dhsdlj O6E jprlftj('Dh fûidrc rdblstregc %g ds ieycr e %g', O, E) dhsd E99O jprlftj('Dh fûidrc rdblstregc %g ds lbueh df eiocs mescs', E) dfg %% 2. Mýiputc gdh jemtcrleh gd uf fûidrc f. ]d mrderå ufe jufmlýf pere qud sd hde gdsgd tdmhegc uf fûidrc f y sd liprlie df peftehhe dh fûidrc y dh jemtcrleh gdh ilsic. mhm, mhder, mhder ehh
E 9 lfput('Glbltd dh fûidrc qud gdsde mehmuher su jemtcrleh; ')0
jcr l95;E iet(5, l)9l0 dfg x9prcg(iet)0 jprlftj('Dh jemtcrleh gd %g ds lbueh e %g', E, x) %% >. ]drld gd Jlocfemml (1, 5, 5, ?, =, 4, >, … ). ]d gdod mrder ufe jufmlýf pere qud sd bdfdrd he sdrld gd Jlocfemml pere hcs prlidrcs f fûidrcs idgleftd uf jcr. Egdiås sd gdod brejlmer f vs. he sdrld. mhm, mhder, mhder ehh f 9 lfput('Glbltd dh fûidrc hliltd gd he sdrld gd Jlocfemml; ')0 E9zdrcs(5, f) E(?)95 E(=)95 jcr l97;5;f
E(l)9 E(l-5)+E(l-?)0 phct(l, E, 'r--*', 'hlfdwlgtn', 4)0 nchg cf dfg
jprlftj('He sdrld gd jlocfemml gd hcs prlidrcs %g vehcrds ds 9 ', f) glsp(E)
%% , … ). ]d gdod mrder ufe jufmlýf pere qud sd bdfdrd he sdrld gd Jlocfemml pere hcs prlidrcs f fûidrcs idgleftd uf wnlhd. Egdiås sd gdod brejlmer f vs. he sdrld. mhm, mhder, mhder ehh f 9 lfput('Glbltd dh fûidrc hliltd gd he sdrld gd Jlocfemml; ')0 E9zdrcs(5, f)0 E(?)950 E(=)950 l970 wnlhd l89f E(l)9 E(l-5)+E(l-?)0 l9l+5 %mcftegcr phct(l, E, 'o--+', 'hlfdwlgtn', 4)0 nchg cf dfg jprlftj('He sdrld gd jlocfemml gd hcs prlidrcs %g vehcrds ds 9 ', f) glsp(E)
%% 51. Crgdfeildftc gd uf errdbhc gd iefdre esmdfgdftd diphdefgc dh ehbcrltic gd ‘crgdfeildftc tlpc ourouke’. Qere lflmler mcf dstd prcbreie sd subldrd utlhlzer uf errdbhc mcf hcs slbuldftds vehcrds df dstd ilsic crgdf; P< = 5> ?4 7 1 52 5> =4 :Y. Dh smrlpt sd gdod hheier esmdfgdftd. mhm, mhder, mhder ehh
Z9 P< = 5> ?4 7 1 52 5> =4 :Y0 glsp('Dh vdmtcr') glsp(Z)0 f9hdfbtn(Z)0 jcr E95;5;f-50 jcr O95;5;f-50 lj Z(O)6Z(O+5)0 tdip9Z(O)0 Z(O)9Z(O+5)0 Z(O+5)9tdip0 dfg dfg dfg glsp('Wldfd mcic sdmudfmle esmdfgdftd') glsp(Z) %% 55. Oûsqudge gd uf iefdre esmdfgdftd, sd he qud sd hcmehlze sl oûsqudge olferle pere
dhdidftc df uf errdbhc. Oesegc df uf errdbhc crgdfegc gd gdod ousmer ufc gd sus dhdidftcs y sd liprlid he pcslmlýf df dstå lfmhulgc df dh errdbhc. ]d userå dh ehbcrltic gd teh jlf
mhm, mhder, mhder ehh L9 50 J9 510 Z9 P1 = 7 : < 52 5> 5> ?4 =4Y0 E9 jehsd0 glsp(']de dh vdmtcr; ') glsp(Z)
^9 lfput('Lfbrdsd ehbufc gd hcs vehcrds gegcs; ') wnlhd (~E&&L 89 J) ilteg9lft=?((L+J)/?)0 lj (^99 Z(ilteg)) E9 trud0 dhsd lj (^8 Z(ilteg))0 J9 ilteg-50 dhsd L9 ilteg+50 dfg dfg dfg lj(E) jprlftj('dh vehcr rdblstregc dstå df he pcslmlýf %g', ilteg) dhsd dfg
glsp('Dh getc fc sd dfmudftre')
View more...
Comments