plot 3 D graph when dimension of matrices doesn't agree
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
yogeshwari patel
il 19 Dic 2021
Commentato: Star Strider
il 20 Dic 2021
x=0:10:400;
t=0:0.5:6;
u=[2.22044604925031e-16 0.0166288189049042 0.0642880296655506 0.136295894416653 0.221516183372431 0.304358174811167 0.364776655053598 0.378271918435164 0.315889767272127 0.144221511821597 0.174596029764522 0.682880531491621 1.42740415958047
0 0.0252212748161491 0.0171825391721578 0.0241709100109577 0.0955651939859084 0.190397852333671 0.298737843113390 0.407325543007541 0.499572747462247 0.555562670822658 0.552049946463282 0.462460626913196 0.256892183976023
2.22044604925031e-16 0.0626926583098169 0.0968227721214796 0.0958344003265919 0.0540371234970884 0.0333939563493764 0.170418215983332 0.360129511196569 0.604756177034229 0.905661028025791 1.26334135841480 1.67742894238721 2.14669003429816
4.44089209850063e-16 0.0895621929224291 0.160399134938379 0.202892835692941 0.206199250953427 0.158248282409471 0.0457437774705489 0.145836470939019 0.432240724587491 0.830443300145495 1.35864456939807 2.03627095945892 2.88397495298674
1.11022302462516e-16 0.103222855837446 0.198964407297011 0.278356202518558 0.330472830341299 0.342331920201796 0.298894142028437 0.183063206132386 0.0243141369049968 0.344448096348266 0.800605841427530 1.41811150146162 2.22434616598477
0 0.104777426549449 0.211411994297151 0.313847867072112 0.404178100578389 0.472644642387087 0.507638331925758 0.495698900465161 0.421514971103342 0.267924058746981 0.0159125700899561 0.355384196410899 0.868682050562910
1.11022302462516e-16 0.0975743070043125 0.202952620102533 0.313079894400546 0.423670085464400 0.529206149367274 0.622940042735313 0.696892722792276 0.741854147402948 0.747383275115283 0.701808065201220 0.592225477696125 0.404501473436821
1.11022302462516e-16 0.0854453470338866 0.181411569975344 0.287066862127012 0.400940231541705 0.520921501085259 0.644261308499304 0.767571106463974 0.886823162660504 0.997350559833687 1.09384719585417 1.17036778378058 1.22032785192136
1.11022302462516e-16 0.0715506699635858 0.154041299361992 0.247934686571858 0.353459338626677 0.470609471271972 0.599145009020947 0.738591585210580 0.888240542058161 1.04714893071826 1.21413951134010 1.38780075312538 1.56648683438644
1.11022302462516e-16 0.0579854184564292 0.126023777278154 0.205163549571495 0.296443695830877 0.400893663977981 0.519533389401461 0.653373294997218 0.803414291209236 0.970647776070974 1.15605563524733 1.36061024207714 1.58527445761629
5.55111512312578e-17 0.0458766023208767 0.100353403522197 0.164632428681744 0.240008146394482 0.327867468796205 0.429689751587656 0.547046794059110 0.681602839115424 0.835114573301574 1.00943112682866 1.20649407360040 1.42833743124014
0 0.0356616312093482 0.0783562324546733 0.129218532557075 0.189508090998130 0.260609297931939 0.344031374197499 0.441408371331389 0.554499171580785 0.685187487916810 0.835481864048216 1.00751567443541 1.20354712430481
2.77555756156289e-17 0.0273639073135483 0.0603103269982884 0.0998162220669246 0.146981748892078 0.203030257210901 0.269308290129878 0.347285584129824 0.438555069071074 0.544832868198884 0.667958298149024 0.809893868953588 0.972725284047015
1.38777878078145e-17 0.0207974469376280 0.0459371635306881 0.0762177594475754 0.112545519850352 0.155934405395165 0.207506052232765 0.268489772009127 0.340222551866171 0.424149054442599 0.521821617874835 0.634900255798076 0.765152657347462
2.77555756156289e-17 0.0156960023265136 0.0347223543627799 0.0577113948165678 0.0853839182342229 0.118549174999043 0.158104871329696 0.205037169278686 0.260420686730858 0.325418497401962 0.401282130837257 0.489351572410173 0.591055263321015
6.93889390390723e-18 0.0117846744774116 0.0260983675533106 0.0434315435765413 0.0643447811697089 0.0894687732267862 0.119504326910734 0.155222363651132 0.197463919141828 0.247140143338592 0.305232300456798 0.372791768969115 0.450940041603208
1.38777878078145e-17 0.00881425989577963 0.0195354705494321 0.0325388318984705 0.0482539043436679 0.0671646087465783 0.0898092264270544 0.116780399160761 0.148725129176686 0.186344779154649 0.230395072222807 0.281686091955159 0.341082282369047
6.93889390390723e-18 0.00657398138624577 0.0145785500996919 0.0242980177718166 0.0360582435825243 0.0502266342578998 0.0672121440679507 0.0874652748243410 0.111478075878113 0.139784144117402 0.172958623965135 0.211618207376729 0.256421133837769
3.46944695195361e-18 0.00489289415913466 0.0108550555300733 0.0181004976235859 0.0268746863475672 0.0374545400051380 0.0501484292927354 0.0652961772981906 0.0832690594987935 0.104469803759347 0.129332590330207 0.158323051845312 0.191938273320201
3.46944695195361e-18 0.00363608693770361 0.00806923323433713 0.0134597784439725 0.0199917168214006 0.0278726973205931 0.0373340235931538 0.0486306539867569 0.0620412015435750 0.0778679339986940 0.0964367737785171 0.118097297999157 0.143222738464816
3.46944695195361e-18 0.00269903343933642 0.00599104881126576 0.00999576771090360 0.0148506208437025 0.0207107480242396 0.0277489981749938 0.0361559293251132 0.0461398086091719 0.0579266122659173 0.0717600256370062 0.0879014431657310 0.106629968395736
1.73472347597681e-18 0.00200178172819858 0.00444408407253482 0.00741608215727646 0.0110201662494413 0.0153719417578584 0.0206002292322210 0.0268470643621311 0.0342676979761353 0.0430305960407531 0.0533174396594956 0.0653231250718765 0.0792557636524135
2.60208521396521e-18 0.00148372993654702 0.00329437188332514 0.00549823048205649 0.00817144918204713 0.0114000102394694 0.0152797347166374 0.0199162824812763 0.0254251522057846 0.0319316813664896 0.0395710462428961 0.0484882619169288 0.0588381822721670
0 0.00109924139808964 0.00244089625581076 0.00407420038642976 0.00605570248326318 0.00844926411913397 0.0113260597458225 0.0147645766935124 0.0188506151702314 0.0236772882612863 0.0293450219286936 0.0359615550106037 0.0436419392207208
8.67361737988404e-19 0.000814110614721873 0.00180787355039329 0.00301781511468002 0.00448589047191536 0.00625948364269071 0.00839140750344217 0.0109399037860333 0.0139686430773337 0.0175467248187937 0.0217486773060150 0.0266544576883167 0.0323494519682981
1.30104260698261e-18 0.000602787686726977 0.00133865900581257 0.00223469263253616 0.00332199389847377 0.00463569479119126 0.00621495395393453 0.00810295668531673 0.0103469149390024 0.0129980673233886 0.0161116791012826 0.0197470421895772 0.0239674751589220
4.33680868994202e-19 0.000446235797421455 0.000991026984444074 0.00165443795577201 0.00245951780008258 0.00343230029979711 0.00460180393084958 0.00600003186245294 0.00766197195686316 0.00962559676914096 0.0119318635469112 0.0146247142301197 0.0177510754507883
0 0.000330296959874073 0.000733562446372728 0.00122465788190963 0.00182065599478672 0.00254084081902357 0.00340670769418494 0.00444196326520669 0.00567252548221998 0.00712652360037366 0.00883429817965497 0.0108284010847084 0.0131435954846529
8.67361737988404e-19 0.000244455862183896 0.000542926984476742 0.000906417946727965 0.00134757107323287 0.00188066643260568 0.00252162183765135 0.00328799284523606 0.00419897275615647 0.00527539261500761 0.00653972121004950 0.00801606507307245 0.00973016847926094
6.50521303491303e-19 0.000180910414633595 0.000401800796583983 0.000670818133430778 0.000997322052201819 0.00139188481927890 0.00186629134030254 0.00243353916007583 0.00310783846246728 0.00390461207031273 0.00484049544531626 0.00593333668795009 0.00720219653735355
0 0.000133875910823272 0.000297340650695549 0.000496424736395178 0.000738056392146084 0.00103006154954782 0.00138116384750494 0.00180098463215559 0.00230004295679952 0.00288975558182521 0.00358243697463636 0.00439129930957767 0.00533045246785979
3.25260651745651e-19 9.90657134285740e-05 0.000220028349408624 0.000367351280599605 0.000546162352333249 0.000762253882561706 0.00102208266180516 0.00133276995309894 0.00170210149194006 0.00213852748623324 0.00265116261623641 0.00324978603450565 0.00394484136583951
2.71050543121376e-19 7.33045671315519e-05 0.000162812907863481 0.000271828228133910 0.000404145517985773 0.000564051551528391 0.000756324886898649 0.000986235866221801 0.00125954661557186 0.00158251104493161 0.00196187484815219 0.00240487550291229 0.00291924227067695
5.42101086242752e-20 5.42411485131173e-05 0.000120472673380293 0.000201139026227538 0.000299048606103171 0.000417373759449363 0.000559650780073378 0.000729779909118538 0.000932025335034888 0.00117101519354956 0.00145174156763686 0.00177956048748802 0.00216019193048067
5.42101086242752e-20 4.01346477132488e-05 8.91416176220543e-05 0.000148829780303930 0.000221277332326542 0.000308831796226626 0.000414110020488700 0.000539998179523559 0.000689651773646551 0.000866495629055638 0.00107422389780923 0.00131680005780380 0.00159845691275128
2.71050543121376e-20 2.96964584113464e-05 6.59578876345220e-05 0.000110122789394033 0.000163728961944055 0.000228513500052827 0.000306412794986889 0.000399562534495163 0.000510297702792869 0.000641152580545276 0.000794860744851302 0.000974355069226932 0.00118276772358848
2.71050543121376e-20 2.19728243995630e-05 4.88032475674786e-05 8.14816898889363e-05 0.000121146043144194 0.000169081670497027 0.000226721406483061 0.000295645556997985 0.000377581899285650 0.000474405681926038 0.000588139624823122 0.000720953919192590 0.000875166227549459]
surf(x,t,u)
0 Commenti
Risposta accettata
Star Strider
il 19 Dic 2021
Just make them match!
Try this —
u=[2.22044604925031e-16 0.0166288189049042 0.0642880296655506 0.136295894416653 0.221516183372431 0.304358174811167 0.364776655053598 0.378271918435164 0.315889767272127 0.144221511821597 0.174596029764522 0.682880531491621 1.42740415958047
0 0.0252212748161491 0.0171825391721578 0.0241709100109577 0.0955651939859084 0.190397852333671 0.298737843113390 0.407325543007541 0.499572747462247 0.555562670822658 0.552049946463282 0.462460626913196 0.256892183976023
2.22044604925031e-16 0.0626926583098169 0.0968227721214796 0.0958344003265919 0.0540371234970884 0.0333939563493764 0.170418215983332 0.360129511196569 0.604756177034229 0.905661028025791 1.26334135841480 1.67742894238721 2.14669003429816
4.44089209850063e-16 0.0895621929224291 0.160399134938379 0.202892835692941 0.206199250953427 0.158248282409471 0.0457437774705489 0.145836470939019 0.432240724587491 0.830443300145495 1.35864456939807 2.03627095945892 2.88397495298674
1.11022302462516e-16 0.103222855837446 0.198964407297011 0.278356202518558 0.330472830341299 0.342331920201796 0.298894142028437 0.183063206132386 0.0243141369049968 0.344448096348266 0.800605841427530 1.41811150146162 2.22434616598477
0 0.104777426549449 0.211411994297151 0.313847867072112 0.404178100578389 0.472644642387087 0.507638331925758 0.495698900465161 0.421514971103342 0.267924058746981 0.0159125700899561 0.355384196410899 0.868682050562910
1.11022302462516e-16 0.0975743070043125 0.202952620102533 0.313079894400546 0.423670085464400 0.529206149367274 0.622940042735313 0.696892722792276 0.741854147402948 0.747383275115283 0.701808065201220 0.592225477696125 0.404501473436821
1.11022302462516e-16 0.0854453470338866 0.181411569975344 0.287066862127012 0.400940231541705 0.520921501085259 0.644261308499304 0.767571106463974 0.886823162660504 0.997350559833687 1.09384719585417 1.17036778378058 1.22032785192136
1.11022302462516e-16 0.0715506699635858 0.154041299361992 0.247934686571858 0.353459338626677 0.470609471271972 0.599145009020947 0.738591585210580 0.888240542058161 1.04714893071826 1.21413951134010 1.38780075312538 1.56648683438644
1.11022302462516e-16 0.0579854184564292 0.126023777278154 0.205163549571495 0.296443695830877 0.400893663977981 0.519533389401461 0.653373294997218 0.803414291209236 0.970647776070974 1.15605563524733 1.36061024207714 1.58527445761629
5.55111512312578e-17 0.0458766023208767 0.100353403522197 0.164632428681744 0.240008146394482 0.327867468796205 0.429689751587656 0.547046794059110 0.681602839115424 0.835114573301574 1.00943112682866 1.20649407360040 1.42833743124014
0 0.0356616312093482 0.0783562324546733 0.129218532557075 0.189508090998130 0.260609297931939 0.344031374197499 0.441408371331389 0.554499171580785 0.685187487916810 0.835481864048216 1.00751567443541 1.20354712430481
2.77555756156289e-17 0.0273639073135483 0.0603103269982884 0.0998162220669246 0.146981748892078 0.203030257210901 0.269308290129878 0.347285584129824 0.438555069071074 0.544832868198884 0.667958298149024 0.809893868953588 0.972725284047015
1.38777878078145e-17 0.0207974469376280 0.0459371635306881 0.0762177594475754 0.112545519850352 0.155934405395165 0.207506052232765 0.268489772009127 0.340222551866171 0.424149054442599 0.521821617874835 0.634900255798076 0.765152657347462
2.77555756156289e-17 0.0156960023265136 0.0347223543627799 0.0577113948165678 0.0853839182342229 0.118549174999043 0.158104871329696 0.205037169278686 0.260420686730858 0.325418497401962 0.401282130837257 0.489351572410173 0.591055263321015
6.93889390390723e-18 0.0117846744774116 0.0260983675533106 0.0434315435765413 0.0643447811697089 0.0894687732267862 0.119504326910734 0.155222363651132 0.197463919141828 0.247140143338592 0.305232300456798 0.372791768969115 0.450940041603208
1.38777878078145e-17 0.00881425989577963 0.0195354705494321 0.0325388318984705 0.0482539043436679 0.0671646087465783 0.0898092264270544 0.116780399160761 0.148725129176686 0.186344779154649 0.230395072222807 0.281686091955159 0.341082282369047
6.93889390390723e-18 0.00657398138624577 0.0145785500996919 0.0242980177718166 0.0360582435825243 0.0502266342578998 0.0672121440679507 0.0874652748243410 0.111478075878113 0.139784144117402 0.172958623965135 0.211618207376729 0.256421133837769
3.46944695195361e-18 0.00489289415913466 0.0108550555300733 0.0181004976235859 0.0268746863475672 0.0374545400051380 0.0501484292927354 0.0652961772981906 0.0832690594987935 0.104469803759347 0.129332590330207 0.158323051845312 0.191938273320201
3.46944695195361e-18 0.00363608693770361 0.00806923323433713 0.0134597784439725 0.0199917168214006 0.0278726973205931 0.0373340235931538 0.0486306539867569 0.0620412015435750 0.0778679339986940 0.0964367737785171 0.118097297999157 0.143222738464816
3.46944695195361e-18 0.00269903343933642 0.00599104881126576 0.00999576771090360 0.0148506208437025 0.0207107480242396 0.0277489981749938 0.0361559293251132 0.0461398086091719 0.0579266122659173 0.0717600256370062 0.0879014431657310 0.106629968395736
1.73472347597681e-18 0.00200178172819858 0.00444408407253482 0.00741608215727646 0.0110201662494413 0.0153719417578584 0.0206002292322210 0.0268470643621311 0.0342676979761353 0.0430305960407531 0.0533174396594956 0.0653231250718765 0.0792557636524135
2.60208521396521e-18 0.00148372993654702 0.00329437188332514 0.00549823048205649 0.00817144918204713 0.0114000102394694 0.0152797347166374 0.0199162824812763 0.0254251522057846 0.0319316813664896 0.0395710462428961 0.0484882619169288 0.0588381822721670
0 0.00109924139808964 0.00244089625581076 0.00407420038642976 0.00605570248326318 0.00844926411913397 0.0113260597458225 0.0147645766935124 0.0188506151702314 0.0236772882612863 0.0293450219286936 0.0359615550106037 0.0436419392207208
8.67361737988404e-19 0.000814110614721873 0.00180787355039329 0.00301781511468002 0.00448589047191536 0.00625948364269071 0.00839140750344217 0.0109399037860333 0.0139686430773337 0.0175467248187937 0.0217486773060150 0.0266544576883167 0.0323494519682981
1.30104260698261e-18 0.000602787686726977 0.00133865900581257 0.00223469263253616 0.00332199389847377 0.00463569479119126 0.00621495395393453 0.00810295668531673 0.0103469149390024 0.0129980673233886 0.0161116791012826 0.0197470421895772 0.0239674751589220
4.33680868994202e-19 0.000446235797421455 0.000991026984444074 0.00165443795577201 0.00245951780008258 0.00343230029979711 0.00460180393084958 0.00600003186245294 0.00766197195686316 0.00962559676914096 0.0119318635469112 0.0146247142301197 0.0177510754507883
0 0.000330296959874073 0.000733562446372728 0.00122465788190963 0.00182065599478672 0.00254084081902357 0.00340670769418494 0.00444196326520669 0.00567252548221998 0.00712652360037366 0.00883429817965497 0.0108284010847084 0.0131435954846529
8.67361737988404e-19 0.000244455862183896 0.000542926984476742 0.000906417946727965 0.00134757107323287 0.00188066643260568 0.00252162183765135 0.00328799284523606 0.00419897275615647 0.00527539261500761 0.00653972121004950 0.00801606507307245 0.00973016847926094
6.50521303491303e-19 0.000180910414633595 0.000401800796583983 0.000670818133430778 0.000997322052201819 0.00139188481927890 0.00186629134030254 0.00243353916007583 0.00310783846246728 0.00390461207031273 0.00484049544531626 0.00593333668795009 0.00720219653735355
0 0.000133875910823272 0.000297340650695549 0.000496424736395178 0.000738056392146084 0.00103006154954782 0.00138116384750494 0.00180098463215559 0.00230004295679952 0.00288975558182521 0.00358243697463636 0.00439129930957767 0.00533045246785979
3.25260651745651e-19 9.90657134285740e-05 0.000220028349408624 0.000367351280599605 0.000546162352333249 0.000762253882561706 0.00102208266180516 0.00133276995309894 0.00170210149194006 0.00213852748623324 0.00265116261623641 0.00324978603450565 0.00394484136583951
2.71050543121376e-19 7.33045671315519e-05 0.000162812907863481 0.000271828228133910 0.000404145517985773 0.000564051551528391 0.000756324886898649 0.000986235866221801 0.00125954661557186 0.00158251104493161 0.00196187484815219 0.00240487550291229 0.00291924227067695
5.42101086242752e-20 5.42411485131173e-05 0.000120472673380293 0.000201139026227538 0.000299048606103171 0.000417373759449363 0.000559650780073378 0.000729779909118538 0.000932025335034888 0.00117101519354956 0.00145174156763686 0.00177956048748802 0.00216019193048067
5.42101086242752e-20 4.01346477132488e-05 8.91416176220543e-05 0.000148829780303930 0.000221277332326542 0.000308831796226626 0.000414110020488700 0.000539998179523559 0.000689651773646551 0.000866495629055638 0.00107422389780923 0.00131680005780380 0.00159845691275128
2.71050543121376e-20 2.96964584113464e-05 6.59578876345220e-05 0.000110122789394033 0.000163728961944055 0.000228513500052827 0.000306412794986889 0.000399562534495163 0.000510297702792869 0.000641152580545276 0.000794860744851302 0.000974355069226932 0.00118276772358848
2.71050543121376e-20 2.19728243995630e-05 4.88032475674786e-05 8.14816898889363e-05 0.000121146043144194 0.000169081670497027 0.000226721406483061 0.000295645556997985 0.000377581899285650 0.000474405681926038 0.000588139624823122 0.000720953919192590 0.000875166227549459];
x = linspace(0, 400, size(u,2));
t = linspace(0, 6, size(u,1));
figure
surfc(x,t,u)
grid on
xlabel('x')
ylabel('t')
zlabel('u')
title('Surface Plot Of \itu(x,t)\rm With Contours')
view(60,30)
.
2 Commenti
Star Strider
il 20 Dic 2021
yogeshwari patel’s ‘Answer’ became this Comment —
x = linspace(0, 400, size(u,2));
t = linspace(0, 6, size(u,1));
size(u,2) ?
can u explain this twwo line what i understands is it will generate the grid 400/size(u,2).
Star Strider
il 20 Dic 2021
Sure.
It does not need to generate a grid (matrix), because the first 2 arguments to surf (or mesh) can either be matrices or vectors. The dimensions simply need to match the third argument (that must be a matrix). So defining them as vectors is good enough, and that is what my correction to the earlier code does.
The easiest way to do this is to use the linspace function, since it allows the most direct control of the vector length.
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Oceanography and Hydrology in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!