Category: Matlab
Category Archives: Matlab
Is there anyway to increase the calculation speed of this sqrt integral2 without loosing accuracy?
Any suggestion to increase the calculation speed of this integral2?
g = @(xx,yy)sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
integral2(g,-1,1,-1,1)Any suggestion to increase the calculation speed of this integral2?
g = @(xx,yy)sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
integral2(g,-1,1,-1,1) Any suggestion to increase the calculation speed of this integral2?
g = @(xx,yy)sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
integral2(g,-1,1,-1,1) integration MATLAB Answers — New Questions
Optimizing a matrix of values
Hi, I need help in optimizing a matrix of values. Assuming a 3×3 matrix, I would have this matrix:
I needed the values of A to F be optimized. What I would usually do is to just take [A B C D E F] as an input value and call it a day. To be fair, this works decently.
My main issue is that my matrix usually changes size, ie. it becomes this:
I will have to change the input to [A B] this time. My question, is, is there a more elegant way of doing these things: Is there a way for me to simply plug in the two matrices without reshaping them and forcing 0 on the diagonal?Hi, I need help in optimizing a matrix of values. Assuming a 3×3 matrix, I would have this matrix:
I needed the values of A to F be optimized. What I would usually do is to just take [A B C D E F] as an input value and call it a day. To be fair, this works decently.
My main issue is that my matrix usually changes size, ie. it becomes this:
I will have to change the input to [A B] this time. My question, is, is there a more elegant way of doing these things: Is there a way for me to simply plug in the two matrices without reshaping them and forcing 0 on the diagonal? Hi, I need help in optimizing a matrix of values. Assuming a 3×3 matrix, I would have this matrix:
I needed the values of A to F be optimized. What I would usually do is to just take [A B C D E F] as an input value and call it a day. To be fair, this works decently.
My main issue is that my matrix usually changes size, ie. it becomes this:
I will have to change the input to [A B] this time. My question, is, is there a more elegant way of doing these things: Is there a way for me to simply plug in the two matrices without reshaping them and forcing 0 on the diagonal? matrix manipulation MATLAB Answers — New Questions
Can Matlab Home run on a Persistent Live Ubuntu USB Stick Operating System?
I anticipate moving from my MS Windows 10 OS to a Ubuntu LTS OS. In preparation for that, I am evaluating several software packages on a "Persistent Live Ubuntu LTS USB Stick Operating System". I have a Matlab Home license on my Windows 10 OS. Can I install and run my Home license on the Ubuntu USB OS?
Once I get all of the apps I need running on the Ubuntu USB OS, I will then replace the Windows 10 OS with the Ubuntu OS. I am using the same HP ZBook for both OSs. (Not at the same time, obviously.) When Microsoft stops supporting Windows 10, I will make the change. My current ZBook will not support Windows 11.
Thanks in advance for your experience and your help.I anticipate moving from my MS Windows 10 OS to a Ubuntu LTS OS. In preparation for that, I am evaluating several software packages on a "Persistent Live Ubuntu LTS USB Stick Operating System". I have a Matlab Home license on my Windows 10 OS. Can I install and run my Home license on the Ubuntu USB OS?
Once I get all of the apps I need running on the Ubuntu USB OS, I will then replace the Windows 10 OS with the Ubuntu OS. I am using the same HP ZBook for both OSs. (Not at the same time, obviously.) When Microsoft stops supporting Windows 10, I will make the change. My current ZBook will not support Windows 11.
Thanks in advance for your experience and your help. I anticipate moving from my MS Windows 10 OS to a Ubuntu LTS OS. In preparation for that, I am evaluating several software packages on a "Persistent Live Ubuntu LTS USB Stick Operating System". I have a Matlab Home license on my Windows 10 OS. Can I install and run my Home license on the Ubuntu USB OS?
Once I get all of the apps I need running on the Ubuntu USB OS, I will then replace the Windows 10 OS with the Ubuntu OS. I am using the same HP ZBook for both OSs. (Not at the same time, obviously.) When Microsoft stops supporting Windows 10, I will make the change. My current ZBook will not support Windows 11.
Thanks in advance for your experience and your help. usb matlab, live usb MATLAB Answers — New Questions
Can Matlab Home run on a Persistent Live Ubuntu USB Stick Operating System?
I anticipate moving from my MS Windows 10 OS to a Ubuntu LTS OS. In preparation for that, I am evaluating several software packages on a "Persistent Live Ubuntu LTS USB Stick Operating System". I have a Matlab Home license on my Windows 10 OS. Can I install and run my Home license on the Ubuntu USB OS?
Once I get all of the apps I need running on the Ubuntu USB OS, I will then replace the Windows 10 OS with the Ubuntu OS. I am using the same HP ZBook for both OSs. (Not at the same time, obviously.) When Microsoft stops supporting Windows 10, I will make the change. My current ZBook will not support Windows 11.
Thanks in advance for your experience and your help.I anticipate moving from my MS Windows 10 OS to a Ubuntu LTS OS. In preparation for that, I am evaluating several software packages on a "Persistent Live Ubuntu LTS USB Stick Operating System". I have a Matlab Home license on my Windows 10 OS. Can I install and run my Home license on the Ubuntu USB OS?
Once I get all of the apps I need running on the Ubuntu USB OS, I will then replace the Windows 10 OS with the Ubuntu OS. I am using the same HP ZBook for both OSs. (Not at the same time, obviously.) When Microsoft stops supporting Windows 10, I will make the change. My current ZBook will not support Windows 11.
Thanks in advance for your experience and your help. I anticipate moving from my MS Windows 10 OS to a Ubuntu LTS OS. In preparation for that, I am evaluating several software packages on a "Persistent Live Ubuntu LTS USB Stick Operating System". I have a Matlab Home license on my Windows 10 OS. Can I install and run my Home license on the Ubuntu USB OS?
Once I get all of the apps I need running on the Ubuntu USB OS, I will then replace the Windows 10 OS with the Ubuntu OS. I am using the same HP ZBook for both OSs. (Not at the same time, obviously.) When Microsoft stops supporting Windows 10, I will make the change. My current ZBook will not support Windows 11.
Thanks in advance for your experience and your help. usb matlab, live usb MATLAB Answers — New Questions
Indexing data on a grid
I have a variable VAR with a size of 360 x 180. I also have an index Ind (composed of 1 and 0) on the same size. How do I get a gridded data at the same size of VAR for data points where Ind == 1. Why doesn’t the below work?
V = VAR(Ind);
V turns into a 1-column data, instead of the expected gridded data.
Thanks.I have a variable VAR with a size of 360 x 180. I also have an index Ind (composed of 1 and 0) on the same size. How do I get a gridded data at the same size of VAR for data points where Ind == 1. Why doesn’t the below work?
V = VAR(Ind);
V turns into a 1-column data, instead of the expected gridded data.
Thanks. I have a variable VAR with a size of 360 x 180. I also have an index Ind (composed of 1 and 0) on the same size. How do I get a gridded data at the same size of VAR for data points where Ind == 1. Why doesn’t the below work?
V = VAR(Ind);
V turns into a 1-column data, instead of the expected gridded data.
Thanks. indexing MATLAB Answers — New Questions
Indexing data on a grid
I have a variable VAR with a size of 360 x 180. I also have an index Ind (composed of 1 and 0) on the same size. How do I get a gridded data at the same size of VAR for data points where Ind == 1. Why doesn’t the below work?
V = VAR(Ind);
V turns into a 1-column data, instead of the expected gridded data.
Thanks.I have a variable VAR with a size of 360 x 180. I also have an index Ind (composed of 1 and 0) on the same size. How do I get a gridded data at the same size of VAR for data points where Ind == 1. Why doesn’t the below work?
V = VAR(Ind);
V turns into a 1-column data, instead of the expected gridded data.
Thanks. I have a variable VAR with a size of 360 x 180. I also have an index Ind (composed of 1 and 0) on the same size. How do I get a gridded data at the same size of VAR for data points where Ind == 1. Why doesn’t the below work?
V = VAR(Ind);
V turns into a 1-column data, instead of the expected gridded data.
Thanks. indexing MATLAB Answers — New Questions
I need to synchronise live camera and lidar how can i do it
Working on sensor fusion project for autonomous vehicles but I cannot synchronise the data between the lidar and cameraWorking on sensor fusion project for autonomous vehicles but I cannot synchronise the data between the lidar and camera Working on sensor fusion project for autonomous vehicles but I cannot synchronise the data between the lidar and camera sensor fusion, lidar, camera MATLAB Answers — New Questions
i have some trouble to create function for Ea approximate error….
hi this is bisection method how do i include approximate error in the table
format short
clear all
clc
u = 2510;
M = 2.8*10^6;
m = 13.3*10^3;
g = 9.81;
v = 335;
n = 4;
t = 0:2:100;
f = @(t) u*log(M./(M-m*t)) – g*t – v;
a = 70;
b = 72;
epsilon = 5*10^(-n-1);
itermax = 20;
x0 = (a+b)/2;
err = abs(f(x0));
iter = 1;
Variables = {‘Iter’, ‘a’, ‘b’, ‘x0’, ‘f_x0’, ‘Error’ , };
HG = [iter a b x0 f(x0) err ];
if f(a)*f(b)>0
disp(‘wrong choice of a and b’);
else
while (iter<=itermax && err>= epsilon)
if f(a)*f(x0)<0
b=x0;
else
a=x0;
end
x0 = (a+b)/2;
err = abs(f(x0));
HG = [HG;iter a b x0 f(x0) err ];
iter = iter+1;
end
end
disp(‘ Itr. No a b x0 f(x0) error’);
disp(HG);hi this is bisection method how do i include approximate error in the table
format short
clear all
clc
u = 2510;
M = 2.8*10^6;
m = 13.3*10^3;
g = 9.81;
v = 335;
n = 4;
t = 0:2:100;
f = @(t) u*log(M./(M-m*t)) – g*t – v;
a = 70;
b = 72;
epsilon = 5*10^(-n-1);
itermax = 20;
x0 = (a+b)/2;
err = abs(f(x0));
iter = 1;
Variables = {‘Iter’, ‘a’, ‘b’, ‘x0’, ‘f_x0’, ‘Error’ , };
HG = [iter a b x0 f(x0) err ];
if f(a)*f(b)>0
disp(‘wrong choice of a and b’);
else
while (iter<=itermax && err>= epsilon)
if f(a)*f(x0)<0
b=x0;
else
a=x0;
end
x0 = (a+b)/2;
err = abs(f(x0));
HG = [HG;iter a b x0 f(x0) err ];
iter = iter+1;
end
end
disp(‘ Itr. No a b x0 f(x0) error’);
disp(HG); hi this is bisection method how do i include approximate error in the table
format short
clear all
clc
u = 2510;
M = 2.8*10^6;
m = 13.3*10^3;
g = 9.81;
v = 335;
n = 4;
t = 0:2:100;
f = @(t) u*log(M./(M-m*t)) – g*t – v;
a = 70;
b = 72;
epsilon = 5*10^(-n-1);
itermax = 20;
x0 = (a+b)/2;
err = abs(f(x0));
iter = 1;
Variables = {‘Iter’, ‘a’, ‘b’, ‘x0’, ‘f_x0’, ‘Error’ , };
HG = [iter a b x0 f(x0) err ];
if f(a)*f(b)>0
disp(‘wrong choice of a and b’);
else
while (iter<=itermax && err>= epsilon)
if f(a)*f(x0)<0
b=x0;
else
a=x0;
end
x0 = (a+b)/2;
err = abs(f(x0));
HG = [HG;iter a b x0 f(x0) err ];
iter = iter+1;
end
end
disp(‘ Itr. No a b x0 f(x0) error’);
disp(HG); bisection MATLAB Answers — New Questions
Simulink example files unable to open
Has anyone had any luck opening the example files from this website? For example the following: https://www.mathworks.com/help/simscape/ug/rankine-cycle-steam-turbine.html
Copy command on top right of screen and insert in Command Window.
I haven’t been able to get one to work yet, and different examples sometime yeild different errors.Has anyone had any luck opening the example files from this website? For example the following: https://www.mathworks.com/help/simscape/ug/rankine-cycle-steam-turbine.html
Copy command on top right of screen and insert in Command Window.
I haven’t been able to get one to work yet, and different examples sometime yeild different errors. Has anyone had any luck opening the example files from this website? For example the following: https://www.mathworks.com/help/simscape/ug/rankine-cycle-steam-turbine.html
Copy command on top right of screen and insert in Command Window.
I haven’t been able to get one to work yet, and different examples sometime yeild different errors. example files MATLAB Answers — New Questions
Issues with using codegen on handle objects with complex methods
I’m running into a fundamental issue with using codegen in my project, and it is unclear if there is a reasonable workaround. I am using several custom handle objects within a ros2 node that are used as inputs to subscription callback functions. In order to have codegen convert all of the internal functions (ie, to fully excercise it), I need to send that node a rather long and complex series of ros2 messages that trigger these various callbacks. In order to generate these messages within the node function itself, I would have to bring in the entire large test script and go through codegen for the whole thing, even though it is irrelevant to the function of the node itself. I addition to this, many of the functions I would need to be able to do so are not supported by codegen, so I would need to rework that entire script to account for that.
What I have tried so far as a workaround is the following:
Place the node generation function within the test script, and output the node and subscriber handles back into the script. This works as intended within normal matlab, but is not supported within codegen since it does not support handle outputs.
If I do not output the node and subscription handle, they are deleted when the function completes. In this case the script runs but none of the callbacks I want to trigger ever get run with the data they need to be thoroughly exercised, since they are triggered by the test script but the handles to which they are associated have been deleted. I can run codegen on this version, but it ultimately runs into the following error after all other errors have been resolved: ‘The library ‘ROS 2 Node’ is not supported by the current target, language or compiler.’
If I add a loop within the function to stop it from completing, it blocks further evaluation of the test script, so the messages never get sent and the callbacks never trigger. I have not tried running codegen on this variation.
At a high level, the test script and node that works look like the following:
%%% Test Script that works but fails codegen %%%
% Set up test node
% Call the node that I am trying to run codegen on
[objectfindernode, objectfindersub]=objectFinderNode()
% Import test data
% Convert test data into msg1 format
% Send msg1 via test node publisher
% Check msg2 via test node subscriber callback
%%% End of test script %%%
%%% Node that works but fails codegen %%%
function [objectfindernode, objectfindersub]=objectFinderNode()
% Initialize handle objects ob1-obn and run needed methods
% build ros2 node ‘objectfindernode’
% Add publisher ‘pub’ that publishes response ‘msg2’
% Add subscriber ‘objectfindersub’ that subcribes to ‘msg1’ with callback
% callback1(ob1,…,obn,pub)
end
function callback1(msg,ob1,..,obn,pub)
% Do handle objects ob1-obn methods
% Populate and send msg2 via pub
end
%%% End of node that works but fails codegen %%%
If I change it to the following, the msg2 check never occurs, indicating that callback 1 never happened. Codegen runs on this version, but I still run into the error: ‘The library ‘ROS 2 Node’ is not supported by the current target, language or compiler.’ I also do not know which parts of the code are actually getting called.
%%% Test Script that does not work correctly and fails codegen differently %%%
% Set up test node
% Call the node that I am trying to run codegen on
[objectfindernode, objectfindersub]=objectFinderNode()
% Import test data
% Convert test data into msg1 format
% Send msg1 via test node publisher
% Check msg2 via test node subscriber callback
%%% End of test script %%%
%%% Node that can run in codegen until the listed error %%%
function objectFinderNode()
% Initialize handle objects ob1-obn and run needed methods
% build ros2 node ‘objectfindernode’
% Add publisher ‘pub’ that publishes response ‘msg2’
% Add subscriber ‘objectfindersub’ that subcribes to ‘msg1’ with callback
% callback1(ob1,…,obn,pub)
end
function callback1(msg,ob1,..,obn,pub)
% Do handle objects ob1-obn methods
% Populate and send msg2 via pub
end
%%% End of node %%%
At this point I am stuck. Unless there are more workarounds that I am not aware of this is questionably feasible project, due to the difficulty involved in generating test data for the node with only the codegen-viable set of functions. Also, I have already applied the workaround shown here for how to fix the ros2subscription callback issues within codegen: https://www.mathworks.com/matlabcentral/answers/1851568-ros2-subscriber-callback-function-arguments-for-code-generation
Separately, are there plans to support handle object generation within loops in the future within codegen? I use cell arrays of handle objects throughout my project, so having to initialize each one individually is very tedious and verbose if it is a large array.I’m running into a fundamental issue with using codegen in my project, and it is unclear if there is a reasonable workaround. I am using several custom handle objects within a ros2 node that are used as inputs to subscription callback functions. In order to have codegen convert all of the internal functions (ie, to fully excercise it), I need to send that node a rather long and complex series of ros2 messages that trigger these various callbacks. In order to generate these messages within the node function itself, I would have to bring in the entire large test script and go through codegen for the whole thing, even though it is irrelevant to the function of the node itself. I addition to this, many of the functions I would need to be able to do so are not supported by codegen, so I would need to rework that entire script to account for that.
What I have tried so far as a workaround is the following:
Place the node generation function within the test script, and output the node and subscriber handles back into the script. This works as intended within normal matlab, but is not supported within codegen since it does not support handle outputs.
If I do not output the node and subscription handle, they are deleted when the function completes. In this case the script runs but none of the callbacks I want to trigger ever get run with the data they need to be thoroughly exercised, since they are triggered by the test script but the handles to which they are associated have been deleted. I can run codegen on this version, but it ultimately runs into the following error after all other errors have been resolved: ‘The library ‘ROS 2 Node’ is not supported by the current target, language or compiler.’
If I add a loop within the function to stop it from completing, it blocks further evaluation of the test script, so the messages never get sent and the callbacks never trigger. I have not tried running codegen on this variation.
At a high level, the test script and node that works look like the following:
%%% Test Script that works but fails codegen %%%
% Set up test node
% Call the node that I am trying to run codegen on
[objectfindernode, objectfindersub]=objectFinderNode()
% Import test data
% Convert test data into msg1 format
% Send msg1 via test node publisher
% Check msg2 via test node subscriber callback
%%% End of test script %%%
%%% Node that works but fails codegen %%%
function [objectfindernode, objectfindersub]=objectFinderNode()
% Initialize handle objects ob1-obn and run needed methods
% build ros2 node ‘objectfindernode’
% Add publisher ‘pub’ that publishes response ‘msg2’
% Add subscriber ‘objectfindersub’ that subcribes to ‘msg1’ with callback
% callback1(ob1,…,obn,pub)
end
function callback1(msg,ob1,..,obn,pub)
% Do handle objects ob1-obn methods
% Populate and send msg2 via pub
end
%%% End of node that works but fails codegen %%%
If I change it to the following, the msg2 check never occurs, indicating that callback 1 never happened. Codegen runs on this version, but I still run into the error: ‘The library ‘ROS 2 Node’ is not supported by the current target, language or compiler.’ I also do not know which parts of the code are actually getting called.
%%% Test Script that does not work correctly and fails codegen differently %%%
% Set up test node
% Call the node that I am trying to run codegen on
[objectfindernode, objectfindersub]=objectFinderNode()
% Import test data
% Convert test data into msg1 format
% Send msg1 via test node publisher
% Check msg2 via test node subscriber callback
%%% End of test script %%%
%%% Node that can run in codegen until the listed error %%%
function objectFinderNode()
% Initialize handle objects ob1-obn and run needed methods
% build ros2 node ‘objectfindernode’
% Add publisher ‘pub’ that publishes response ‘msg2’
% Add subscriber ‘objectfindersub’ that subcribes to ‘msg1’ with callback
% callback1(ob1,…,obn,pub)
end
function callback1(msg,ob1,..,obn,pub)
% Do handle objects ob1-obn methods
% Populate and send msg2 via pub
end
%%% End of node %%%
At this point I am stuck. Unless there are more workarounds that I am not aware of this is questionably feasible project, due to the difficulty involved in generating test data for the node with only the codegen-viable set of functions. Also, I have already applied the workaround shown here for how to fix the ros2subscription callback issues within codegen: https://www.mathworks.com/matlabcentral/answers/1851568-ros2-subscriber-callback-function-arguments-for-code-generation
Separately, are there plans to support handle object generation within loops in the future within codegen? I use cell arrays of handle objects throughout my project, so having to initialize each one individually is very tedious and verbose if it is a large array. I’m running into a fundamental issue with using codegen in my project, and it is unclear if there is a reasonable workaround. I am using several custom handle objects within a ros2 node that are used as inputs to subscription callback functions. In order to have codegen convert all of the internal functions (ie, to fully excercise it), I need to send that node a rather long and complex series of ros2 messages that trigger these various callbacks. In order to generate these messages within the node function itself, I would have to bring in the entire large test script and go through codegen for the whole thing, even though it is irrelevant to the function of the node itself. I addition to this, many of the functions I would need to be able to do so are not supported by codegen, so I would need to rework that entire script to account for that.
What I have tried so far as a workaround is the following:
Place the node generation function within the test script, and output the node and subscriber handles back into the script. This works as intended within normal matlab, but is not supported within codegen since it does not support handle outputs.
If I do not output the node and subscription handle, they are deleted when the function completes. In this case the script runs but none of the callbacks I want to trigger ever get run with the data they need to be thoroughly exercised, since they are triggered by the test script but the handles to which they are associated have been deleted. I can run codegen on this version, but it ultimately runs into the following error after all other errors have been resolved: ‘The library ‘ROS 2 Node’ is not supported by the current target, language or compiler.’
If I add a loop within the function to stop it from completing, it blocks further evaluation of the test script, so the messages never get sent and the callbacks never trigger. I have not tried running codegen on this variation.
At a high level, the test script and node that works look like the following:
%%% Test Script that works but fails codegen %%%
% Set up test node
% Call the node that I am trying to run codegen on
[objectfindernode, objectfindersub]=objectFinderNode()
% Import test data
% Convert test data into msg1 format
% Send msg1 via test node publisher
% Check msg2 via test node subscriber callback
%%% End of test script %%%
%%% Node that works but fails codegen %%%
function [objectfindernode, objectfindersub]=objectFinderNode()
% Initialize handle objects ob1-obn and run needed methods
% build ros2 node ‘objectfindernode’
% Add publisher ‘pub’ that publishes response ‘msg2’
% Add subscriber ‘objectfindersub’ that subcribes to ‘msg1’ with callback
% callback1(ob1,…,obn,pub)
end
function callback1(msg,ob1,..,obn,pub)
% Do handle objects ob1-obn methods
% Populate and send msg2 via pub
end
%%% End of node that works but fails codegen %%%
If I change it to the following, the msg2 check never occurs, indicating that callback 1 never happened. Codegen runs on this version, but I still run into the error: ‘The library ‘ROS 2 Node’ is not supported by the current target, language or compiler.’ I also do not know which parts of the code are actually getting called.
%%% Test Script that does not work correctly and fails codegen differently %%%
% Set up test node
% Call the node that I am trying to run codegen on
[objectfindernode, objectfindersub]=objectFinderNode()
% Import test data
% Convert test data into msg1 format
% Send msg1 via test node publisher
% Check msg2 via test node subscriber callback
%%% End of test script %%%
%%% Node that can run in codegen until the listed error %%%
function objectFinderNode()
% Initialize handle objects ob1-obn and run needed methods
% build ros2 node ‘objectfindernode’
% Add publisher ‘pub’ that publishes response ‘msg2’
% Add subscriber ‘objectfindersub’ that subcribes to ‘msg1’ with callback
% callback1(ob1,…,obn,pub)
end
function callback1(msg,ob1,..,obn,pub)
% Do handle objects ob1-obn methods
% Populate and send msg2 via pub
end
%%% End of node %%%
At this point I am stuck. Unless there are more workarounds that I am not aware of this is questionably feasible project, due to the difficulty involved in generating test data for the node with only the codegen-viable set of functions. Also, I have already applied the workaround shown here for how to fix the ros2subscription callback issues within codegen: https://www.mathworks.com/matlabcentral/answers/1851568-ros2-subscriber-callback-function-arguments-for-code-generation
Separately, are there plans to support handle object generation within loops in the future within codegen? I use cell arrays of handle objects throughout my project, so having to initialize each one individually is very tedious and verbose if it is a large array. ros2, matlab coder MATLAB Answers — New Questions
getting negative open voltage in pv array
hello,
I model pv array block with input excel using signal editor and repeating sequences. I just put goto block in ‘m’ port of pv array to see voltage diagram. after i run my voltage which is open circuit voltage is in negative part of V-t
if anyone what is my problem please help me.hello,
I model pv array block with input excel using signal editor and repeating sequences. I just put goto block in ‘m’ port of pv array to see voltage diagram. after i run my voltage which is open circuit voltage is in negative part of V-t
if anyone what is my problem please help me. hello,
I model pv array block with input excel using signal editor and repeating sequences. I just put goto block in ‘m’ port of pv array to see voltage diagram. after i run my voltage which is open circuit voltage is in negative part of V-t
if anyone what is my problem please help me. pv array MATLAB Answers — New Questions
Make the colours of my graph continuous
Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
ThibaultHello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault plot, matlab, graphic representation, shading interpolation MATLAB Answers — New Questions
Parallel Simulation VERY slow?
I have created a Simulink file which runs in 99 seconds. I decided to use parsim in matlab to make it even faster. I used the time step required for the workers to start in different time (and use specific data) and run this faster, but instead it requires 5100 seconds (~85 minutes). My guess would be that each worker uses ALL the data, and possibly runs the entirety of the simulation.
Below is the code I created. What do I need to change so that I can make it faster, or at least working properly, meaning that each worker will use the specified data (for example data between 0.04-0.08) and run this specific time.
% Create a parallel pool if not already available
if isempty(gcp(‘nocreate’))
parpool; % Create a parallel pool
end
% Load Model
model = ‘zigzag_example_matlab’;
load_system(model);
% Sweep parameters
sweep = (0.00:0.04:3.84);
numSims = numel(sweep);
% Preallocate SimulationInput array
simIn = Simulink.SimulationInput.empty(numSims, 0);
% Cell array of variable names
variableNames = {‘From Workspace’, ‘From Workspace1’, ‘From Workspace2’, ‘From Workspace3’, ‘From Workspace4’, …
‘From Workspace5’, ‘From Workspace6’, ‘From Workspace7’, ‘From Workspace8’, ‘From Workspace9’, …
‘From Workspace10’, ‘From Workspace11’};
% Create an array of SimulationInput objects and specify the sweep value for each simulation
for idx = 1:numSims
simIn(idx) = Simulink.SimulationInput(model);
% Set ‘SampleTime’ for each variable
for varIdx = 1:numel(variableNames)
variablePath = sprintf(‘zigzag_example_matlab/%s’, variableNames{varIdx});
simIn(idx) = simIn(idx).setBlockParameter(variablePath, ‘SampleTime’, num2str(sweep(idx)));
end
end
% Simulate the model
tic
simOut = parsim(simIn, ‘TransferBaseWorkspaceVariables’, ‘on’, ‘ShowSimulationManager’, ‘on’);
tocI have created a Simulink file which runs in 99 seconds. I decided to use parsim in matlab to make it even faster. I used the time step required for the workers to start in different time (and use specific data) and run this faster, but instead it requires 5100 seconds (~85 minutes). My guess would be that each worker uses ALL the data, and possibly runs the entirety of the simulation.
Below is the code I created. What do I need to change so that I can make it faster, or at least working properly, meaning that each worker will use the specified data (for example data between 0.04-0.08) and run this specific time.
% Create a parallel pool if not already available
if isempty(gcp(‘nocreate’))
parpool; % Create a parallel pool
end
% Load Model
model = ‘zigzag_example_matlab’;
load_system(model);
% Sweep parameters
sweep = (0.00:0.04:3.84);
numSims = numel(sweep);
% Preallocate SimulationInput array
simIn = Simulink.SimulationInput.empty(numSims, 0);
% Cell array of variable names
variableNames = {‘From Workspace’, ‘From Workspace1’, ‘From Workspace2’, ‘From Workspace3’, ‘From Workspace4’, …
‘From Workspace5’, ‘From Workspace6’, ‘From Workspace7’, ‘From Workspace8’, ‘From Workspace9’, …
‘From Workspace10’, ‘From Workspace11’};
% Create an array of SimulationInput objects and specify the sweep value for each simulation
for idx = 1:numSims
simIn(idx) = Simulink.SimulationInput(model);
% Set ‘SampleTime’ for each variable
for varIdx = 1:numel(variableNames)
variablePath = sprintf(‘zigzag_example_matlab/%s’, variableNames{varIdx});
simIn(idx) = simIn(idx).setBlockParameter(variablePath, ‘SampleTime’, num2str(sweep(idx)));
end
end
% Simulate the model
tic
simOut = parsim(simIn, ‘TransferBaseWorkspaceVariables’, ‘on’, ‘ShowSimulationManager’, ‘on’);
toc I have created a Simulink file which runs in 99 seconds. I decided to use parsim in matlab to make it even faster. I used the time step required for the workers to start in different time (and use specific data) and run this faster, but instead it requires 5100 seconds (~85 minutes). My guess would be that each worker uses ALL the data, and possibly runs the entirety of the simulation.
Below is the code I created. What do I need to change so that I can make it faster, or at least working properly, meaning that each worker will use the specified data (for example data between 0.04-0.08) and run this specific time.
% Create a parallel pool if not already available
if isempty(gcp(‘nocreate’))
parpool; % Create a parallel pool
end
% Load Model
model = ‘zigzag_example_matlab’;
load_system(model);
% Sweep parameters
sweep = (0.00:0.04:3.84);
numSims = numel(sweep);
% Preallocate SimulationInput array
simIn = Simulink.SimulationInput.empty(numSims, 0);
% Cell array of variable names
variableNames = {‘From Workspace’, ‘From Workspace1’, ‘From Workspace2’, ‘From Workspace3’, ‘From Workspace4’, …
‘From Workspace5’, ‘From Workspace6’, ‘From Workspace7’, ‘From Workspace8’, ‘From Workspace9’, …
‘From Workspace10’, ‘From Workspace11’};
% Create an array of SimulationInput objects and specify the sweep value for each simulation
for idx = 1:numSims
simIn(idx) = Simulink.SimulationInput(model);
% Set ‘SampleTime’ for each variable
for varIdx = 1:numel(variableNames)
variablePath = sprintf(‘zigzag_example_matlab/%s’, variableNames{varIdx});
simIn(idx) = simIn(idx).setBlockParameter(variablePath, ‘SampleTime’, num2str(sweep(idx)));
end
end
% Simulate the model
tic
simOut = parsim(simIn, ‘TransferBaseWorkspaceVariables’, ‘on’, ‘ShowSimulationManager’, ‘on’);
toc matlab, parallel computing toolbox, simulink, simulation MATLAB Answers — New Questions
Make the colours of my graph continuous
Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
ThibaultHello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault plot, matlab, graphic representation, shading interpolation MATLAB Answers — New Questions
Make the colours of my graph continuous
Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
ThibaultHello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault Hello,
I want to graphically represent several layers of material and their thermal heating. My first code works and I get rectangles with colour calibration according to their temperature (the hotter the layer of material, the redder it will be).
My aim now is to "smooth" the colours together so that the rectangles are no longer distinguishable but the colours are continuous and the rendering is more homogenous. I’ve already tried using shading interp or patch but I can’t manage to integrate them correctly without getting error messages!
How can I achieve this? Could you suggest a code to go with the one already written?
Thanks in advance
Thibault plot, matlab, graphic representation, shading interpolation MATLAB Answers — New Questions
xcorr results: c written in long format, lags in wide format
I want to calculate the cross-correlation between ankle and hip movement.
My data are organised in a structure: model.filt.modelOutputs with 12500×3 matrices.
I attached an example file with only the filtered Ankle and Hip angles.
The data contains several movement cycles which can be identified by the starting frames stored in tStart.
When I use [c, lags] = xcorr, I get c as 1301×1 double and lags as 1×1301 double.
Can anyone explain, why this happens? When I use different example vectors, both results have the same orientation.
This is the part of my code, which reproduces the results::
load modelExample.mat
tStart = [1,611,1261];
[c, lags] = xcorr(modelExample.filt.RAnkleAngles(tStart(2):tStart(3),2), modelExample.filt.RHipAngles(tStart(2):tStart(3),2), ‘normalized’);I want to calculate the cross-correlation between ankle and hip movement.
My data are organised in a structure: model.filt.modelOutputs with 12500×3 matrices.
I attached an example file with only the filtered Ankle and Hip angles.
The data contains several movement cycles which can be identified by the starting frames stored in tStart.
When I use [c, lags] = xcorr, I get c as 1301×1 double and lags as 1×1301 double.
Can anyone explain, why this happens? When I use different example vectors, both results have the same orientation.
This is the part of my code, which reproduces the results::
load modelExample.mat
tStart = [1,611,1261];
[c, lags] = xcorr(modelExample.filt.RAnkleAngles(tStart(2):tStart(3),2), modelExample.filt.RHipAngles(tStart(2):tStart(3),2), ‘normalized’); I want to calculate the cross-correlation between ankle and hip movement.
My data are organised in a structure: model.filt.modelOutputs with 12500×3 matrices.
I attached an example file with only the filtered Ankle and Hip angles.
The data contains several movement cycles which can be identified by the starting frames stored in tStart.
When I use [c, lags] = xcorr, I get c as 1301×1 double and lags as 1×1301 double.
Can anyone explain, why this happens? When I use different example vectors, both results have the same orientation.
This is the part of my code, which reproduces the results::
load modelExample.mat
tStart = [1,611,1261];
[c, lags] = xcorr(modelExample.filt.RAnkleAngles(tStart(2):tStart(3),2), modelExample.filt.RHipAngles(tStart(2):tStart(3),2), ‘normalized’); xcorr MATLAB Answers — New Questions
Upgraded Matlab from 2022b to 2023b and I’ve noticed a floating point error
I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I’m sure my code hasn’t changed at all so its unclear what’s happened. Any ideas why this change has happened?I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I’m sure my code hasn’t changed at all so its unclear what’s happened. Any ideas why this change has happened? I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I’m sure my code hasn’t changed at all so its unclear what’s happened. Any ideas why this change has happened? 2023b MATLAB Answers — New Questions
Upgraded Matlab from 2022b to 2023b and I’ve noticed a floating point error
I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I’m sure my code hasn’t changed at all so its unclear what’s happened. Any ideas why this change has happened?I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I’m sure my code hasn’t changed at all so its unclear what’s happened. Any ideas why this change has happened? I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I’m sure my code hasn’t changed at all so its unclear what’s happened. Any ideas why this change has happened? 2023b MATLAB Answers — New Questions
Parallel Simulation VERY slow?
I have created a Simulink file which runs in 99 seconds. I decided to use parsim in matlab to make it even faster. I used the time step required for the workers to start in different time (and use specific data) and run this faster, but instead it requires 5100 seconds (~85 minutes). My guess would be that each worker uses ALL the data, and possibly runs the entirety of the simulation.
Below is the code I created. What do I need to change so that I can make it faster, or at least working properly, meaning that each worker will use the specified data (for example data between 0.04-0.08) and run this specific time.
% Create a parallel pool if not already available
if isempty(gcp(‘nocreate’))
parpool; % Create a parallel pool
end
% Load Model
model = ‘zigzag_example_matlab’;
load_system(model);
% Sweep parameters
sweep = (0.00:0.04:3.84);
numSims = numel(sweep);
% Preallocate SimulationInput array
simIn = Simulink.SimulationInput.empty(numSims, 0);
% Cell array of variable names
variableNames = {‘From Workspace’, ‘From Workspace1’, ‘From Workspace2’, ‘From Workspace3’, ‘From Workspace4’, …
‘From Workspace5’, ‘From Workspace6’, ‘From Workspace7’, ‘From Workspace8’, ‘From Workspace9’, …
‘From Workspace10’, ‘From Workspace11’};
% Create an array of SimulationInput objects and specify the sweep value for each simulation
for idx = 1:numSims
simIn(idx) = Simulink.SimulationInput(model);
% Set ‘SampleTime’ for each variable
for varIdx = 1:numel(variableNames)
variablePath = sprintf(‘zigzag_example_matlab/%s’, variableNames{varIdx});
simIn(idx) = simIn(idx).setBlockParameter(variablePath, ‘SampleTime’, num2str(sweep(idx)));
end
end
% Simulate the model
tic
simOut = parsim(simIn, ‘TransferBaseWorkspaceVariables’, ‘on’, ‘ShowSimulationManager’, ‘on’);
tocI have created a Simulink file which runs in 99 seconds. I decided to use parsim in matlab to make it even faster. I used the time step required for the workers to start in different time (and use specific data) and run this faster, but instead it requires 5100 seconds (~85 minutes). My guess would be that each worker uses ALL the data, and possibly runs the entirety of the simulation.
Below is the code I created. What do I need to change so that I can make it faster, or at least working properly, meaning that each worker will use the specified data (for example data between 0.04-0.08) and run this specific time.
% Create a parallel pool if not already available
if isempty(gcp(‘nocreate’))
parpool; % Create a parallel pool
end
% Load Model
model = ‘zigzag_example_matlab’;
load_system(model);
% Sweep parameters
sweep = (0.00:0.04:3.84);
numSims = numel(sweep);
% Preallocate SimulationInput array
simIn = Simulink.SimulationInput.empty(numSims, 0);
% Cell array of variable names
variableNames = {‘From Workspace’, ‘From Workspace1’, ‘From Workspace2’, ‘From Workspace3’, ‘From Workspace4’, …
‘From Workspace5’, ‘From Workspace6’, ‘From Workspace7’, ‘From Workspace8’, ‘From Workspace9’, …
‘From Workspace10’, ‘From Workspace11’};
% Create an array of SimulationInput objects and specify the sweep value for each simulation
for idx = 1:numSims
simIn(idx) = Simulink.SimulationInput(model);
% Set ‘SampleTime’ for each variable
for varIdx = 1:numel(variableNames)
variablePath = sprintf(‘zigzag_example_matlab/%s’, variableNames{varIdx});
simIn(idx) = simIn(idx).setBlockParameter(variablePath, ‘SampleTime’, num2str(sweep(idx)));
end
end
% Simulate the model
tic
simOut = parsim(simIn, ‘TransferBaseWorkspaceVariables’, ‘on’, ‘ShowSimulationManager’, ‘on’);
toc I have created a Simulink file which runs in 99 seconds. I decided to use parsim in matlab to make it even faster. I used the time step required for the workers to start in different time (and use specific data) and run this faster, but instead it requires 5100 seconds (~85 minutes). My guess would be that each worker uses ALL the data, and possibly runs the entirety of the simulation.
Below is the code I created. What do I need to change so that I can make it faster, or at least working properly, meaning that each worker will use the specified data (for example data between 0.04-0.08) and run this specific time.
% Create a parallel pool if not already available
if isempty(gcp(‘nocreate’))
parpool; % Create a parallel pool
end
% Load Model
model = ‘zigzag_example_matlab’;
load_system(model);
% Sweep parameters
sweep = (0.00:0.04:3.84);
numSims = numel(sweep);
% Preallocate SimulationInput array
simIn = Simulink.SimulationInput.empty(numSims, 0);
% Cell array of variable names
variableNames = {‘From Workspace’, ‘From Workspace1’, ‘From Workspace2’, ‘From Workspace3’, ‘From Workspace4’, …
‘From Workspace5’, ‘From Workspace6’, ‘From Workspace7’, ‘From Workspace8’, ‘From Workspace9’, …
‘From Workspace10’, ‘From Workspace11’};
% Create an array of SimulationInput objects and specify the sweep value for each simulation
for idx = 1:numSims
simIn(idx) = Simulink.SimulationInput(model);
% Set ‘SampleTime’ for each variable
for varIdx = 1:numel(variableNames)
variablePath = sprintf(‘zigzag_example_matlab/%s’, variableNames{varIdx});
simIn(idx) = simIn(idx).setBlockParameter(variablePath, ‘SampleTime’, num2str(sweep(idx)));
end
end
% Simulate the model
tic
simOut = parsim(simIn, ‘TransferBaseWorkspaceVariables’, ‘on’, ‘ShowSimulationManager’, ‘on’);
toc matlab, parallel computing toolbox, simulink, simulation MATLAB Answers — New Questions
How we can do the matrix and vector in vector form?
clc;
clear all ;
close all;
format long g;
%% developing the function for the reverse in the vector concate and reverse it
A = [1;2;3]
B = [4 5 6;8 9 11]
[numRows,numCols] = size(B)
%% new vector will be vector form
C = vertcat(A,[B])clc;
clear all ;
close all;
format long g;
%% developing the function for the reverse in the vector concate and reverse it
A = [1;2;3]
B = [4 5 6;8 9 11]
[numRows,numCols] = size(B)
%% new vector will be vector form
C = vertcat(A,[B]) clc;
clear all ;
close all;
format long g;
%% developing the function for the reverse in the vector concate and reverse it
A = [1;2;3]
B = [4 5 6;8 9 11]
[numRows,numCols] = size(B)
%% new vector will be vector form
C = vertcat(A,[B]) vector, mathematics, matlab, matrix, array, arrays, cell MATLAB Answers — New Questions