How to replace the values of a vector from desired location to its end?
Ältere Kommentare anzeigen
I have three vectors a, b and c given below. I want to replace all the values of 'a' from my desired location say for example from location 60 to its end such that those new values are asympotically decreasing from its previous values (i.e., location 1 to 59) and are also less in values from the values of vector b and c from the same location i.e., 60 to the last. One method is manual but its very time consuming. I want that MATLAB should do it for me.
a=[0.397514402866404 0.349231851271051 0.425836326161108 0.418823411789294 0.386696621928579 0.384575525674989 0.364845287492425 0.495928922548383 0.479694820530569 0.389582032512016 0.384505211980922 0.333724865928879 0.365919184423201 0.400772506172964 0.379242722219023 0.364459695600443 0.366128522849086 0.385174773969786 0.372867063392224 0.376548774132535 0.473071808102272 0.251627836852150 0.385042011392780 0.381148165802822 0.369065536223563 0.431444009941580 0.414879010564463 0.325227505916048 0.437887598814955 0.428837027000730 0.406640068369860 0.409409452088121 0.424434292672168 0.409932466026339 0.412835839983982 0.399245885507425 0.387575414369059 0.407050454183416 0.326211795299434 0.458434548036028 0.338455259025878 0.368562202826825 0.413767382594240 0.458452216705265 0.432455960242579 0.415225789491909 0.389509369547427 0.408404223427086 0.320887810417104 0.419718890158122 0.411956096059551 0.467265991314386 0.425563572738537 0.457286988716662 0.364096160999733 0.417395179173226 0.415151032279429 0.439401358954262 0.416025807219374 0.349557755864473 0.413126979577490 0.382242156796521 0.387869720649921 0.344424085502606 0.418357738224712 0.393375703492509 0.410207735948398 0.432538723781336 0.460651539221876 0.366947323455358 0.343158385463345 0.360779192277814 0.407775542134092 0.401720168768703 0.411858470659967 0.390296201351616 0.386700151754722 0.393559416101593 0.405571260599836 0.426038375438873 0.351052078565856 0.417357035534662 0.441552934076875 0.400293564991402 0.396957107193780 0.357192556998893 0.431047692995460 0.383175812178153 0.446884989308566 0.441112998092938 0.421424171377919 0.426723330306019 0.311409378918779 0.383676813236671 0.312569975506430 0.429482861741989 0.411346818807958 0.351598372195988 0.387493340782735 0.464061121524104];
b=[0.551682651670431 0.645096882777877 0.581684008069165 0.506704132814463 0.576791071314667 0.598095975405639 0.556468410315606 0.603215166364727 0.573881723497337 0.702829523545135 0.655401596692394 0.637834736633294 0.569663359602261 0.634042823056570 0.520415579093006 0.557141591176942 0.583010935305893 0.520542027714726 0.593618261801875 0.491359612337422 0.541672987084530 0.623432585679211 0.486386829534579 0.604580199387316 0.673723294633068 0.547784751842482 0.633068049834673 0.592470280261216 0.635036043068146 0.584179124192050 0.566186813602900 0.590306702135361 0.592142837346948 0.645760363411235 0.529148516876326 0.542359452487705 0.576111765619481 0.440572920274603 0.673125819553129 0.552989311869312 0.810202391087325 0.616215986476514 0.637502718705395 0.510482159785954 0.636855535171597 0.640515935733207 0.614862120663137 0.602807491865895 0.576035793127878 0.591165927487269 0.574446655730001 0.569647577308512 0.770477592901505 0.555931615848446 0.559585144340360 0.580838963787409 0.675838792335884 0.539290120744169 0.630342008576237 0.614578423728421 0.514912997133050 0.570801392261179 0.557904302582161 0.516333537322627 0.564906015777891 0.578745862292832 0.633282156008040 0.566117556674110 0.620214334996768 0.603670500271155 0.574218976104897 0.567667037444456 0.509795475612059 0.523914908058583 0.636086852547285 0.552641580772836 0.522137540787447 0.499410785060553 0.537599355871173 0.740725123231447 0.646255524703763 0.616982399812298 0.691986273761024 0.661806826749363 0.586985183103399 0.552227356972073 0.576677035029797 0.535296631878600 0.560018190112691 0.616588660122031 0.674001758525734 0.539967859639179 0.515501886822976 0.552872905239819 0.575552960829275 0.528735725333748 0.673536000041314 0.616306055966220 0.596732320262772 0.620430313847279];
c=[1.11459952996087 1.68670358870423 1.22532598107866 0.624815936271779 0.554255279167175 1.15749032120038 0.572704247243950 0.818472371403532 0.610108820878572 0.520393200082739 0.877109078448262 0.584376156817110 0.864813871234754 0.737829446874604 0.580997699895747 1.77068479618745 0.539182799387493 1.62437864878862 0.521003914004704 0.849895522917450 0.577263897904287 0.526984303503854 1.64990069405968 1.53080783202811 0.896341460688281 0.691820506571966 0.839658467823829 0.916296633939690 1.57481829415576 1.11756769475573 0.496358173351652 0.758366460593150 0.603591262006390 0.856744750071039 0.634025989346108 0.862693031299083 0.499801270339618 1.31880150505211 0.497983284511088 0.955339233571990 0.607304623078370 0.720711362625385 0.662375530565266 0.794992908912330 1.27508484531957 0.681838541650462 1.39432785905121 0.921767072964069 0.732218886357660 1.62092196497150 1.05716708049553 0.921938203224915 0.972931972055981 0.785631875908351 0.762332383313575 0.939098232445008 0.495829657412097 0.734698073565044 0.854786553397547 0.766021749291286 0.757263163382394 0.528035422450610 1.76412942257156 0.480878637061892 0.779087865119777 0.444875526901451 0.702140015667567 0.475393228042059 0.768312696667354 0.638589873668904 1.27460847277030 1.48937825107580 0.495231950051789 0.493444405935982 0.504732624749794 0.631618660777873 1.27292293987335 0.628781242055882 0.488060785261759 0.554757947749088 1.66634519190679 0.900376834938410 1.10921191147181 1.66756865514712 0.574270568683960 1.70204892135356 0.920784050984837 0.538263886964218 1.76503134659234 0.628734987014323 0.595634664706628 0.509007492420166 0.621106010756416 0.860695885662515 1.58470245060019 0.742921218056206 0.756422431551545 0.640398131277412 1.29779726790267 0.523270699017041];
7 Kommentare
I've plotted your values here. Replacing values from 60 to the end is easy, because you can just refer to
a(60:end)
But your description of how you want to replace them is unclear to me.
What do you mean by "asympotically decreasing"? Decreasing to what value? Zero? Do you have a formula for how to calculate the 60:end values from the 1:59 values?
(All the values of a are less than all the values of b and c, so that part seems to be an unnecessary consideration.)
a=[0.397514402866404 0.349231851271051 0.425836326161108 0.418823411789294 0.386696621928579 0.384575525674989 0.364845287492425 0.495928922548383 0.479694820530569 0.389582032512016 0.384505211980922 0.333724865928879 0.365919184423201 0.400772506172964 0.379242722219023 0.364459695600443 0.366128522849086 0.385174773969786 0.372867063392224 0.376548774132535 0.473071808102272 0.251627836852150 0.385042011392780 0.381148165802822 0.369065536223563 0.431444009941580 0.414879010564463 0.325227505916048 0.437887598814955 0.428837027000730 0.406640068369860 0.409409452088121 0.424434292672168 0.409932466026339 0.412835839983982 0.399245885507425 0.387575414369059 0.407050454183416 0.326211795299434 0.458434548036028 0.338455259025878 0.368562202826825 0.413767382594240 0.458452216705265 0.432455960242579 0.415225789491909 0.389509369547427 0.408404223427086 0.320887810417104 0.419718890158122 0.411956096059551 0.467265991314386 0.425563572738537 0.457286988716662 0.364096160999733 0.417395179173226 0.415151032279429 0.439401358954262 0.416025807219374 0.349557755864473 0.413126979577490 0.382242156796521 0.387869720649921 0.344424085502606 0.418357738224712 0.393375703492509 0.410207735948398 0.432538723781336 0.460651539221876 0.366947323455358 0.343158385463345 0.360779192277814 0.407775542134092 0.401720168768703 0.411858470659967 0.390296201351616 0.386700151754722 0.393559416101593 0.405571260599836 0.426038375438873 0.351052078565856 0.417357035534662 0.441552934076875 0.400293564991402 0.396957107193780 0.357192556998893 0.431047692995460 0.383175812178153 0.446884989308566 0.441112998092938 0.421424171377919 0.426723330306019 0.311409378918779 0.383676813236671 0.312569975506430 0.429482861741989 0.411346818807958 0.351598372195988 0.387493340782735 0.464061121524104];
b=[0.551682651670431 0.645096882777877 0.581684008069165 0.506704132814463 0.576791071314667 0.598095975405639 0.556468410315606 0.603215166364727 0.573881723497337 0.702829523545135 0.655401596692394 0.637834736633294 0.569663359602261 0.634042823056570 0.520415579093006 0.557141591176942 0.583010935305893 0.520542027714726 0.593618261801875 0.491359612337422 0.541672987084530 0.623432585679211 0.486386829534579 0.604580199387316 0.673723294633068 0.547784751842482 0.633068049834673 0.592470280261216 0.635036043068146 0.584179124192050 0.566186813602900 0.590306702135361 0.592142837346948 0.645760363411235 0.529148516876326 0.542359452487705 0.576111765619481 0.440572920274603 0.673125819553129 0.552989311869312 0.810202391087325 0.616215986476514 0.637502718705395 0.510482159785954 0.636855535171597 0.640515935733207 0.614862120663137 0.602807491865895 0.576035793127878 0.591165927487269 0.574446655730001 0.569647577308512 0.770477592901505 0.555931615848446 0.559585144340360 0.580838963787409 0.675838792335884 0.539290120744169 0.630342008576237 0.614578423728421 0.514912997133050 0.570801392261179 0.557904302582161 0.516333537322627 0.564906015777891 0.578745862292832 0.633282156008040 0.566117556674110 0.620214334996768 0.603670500271155 0.574218976104897 0.567667037444456 0.509795475612059 0.523914908058583 0.636086852547285 0.552641580772836 0.522137540787447 0.499410785060553 0.537599355871173 0.740725123231447 0.646255524703763 0.616982399812298 0.691986273761024 0.661806826749363 0.586985183103399 0.552227356972073 0.576677035029797 0.535296631878600 0.560018190112691 0.616588660122031 0.674001758525734 0.539967859639179 0.515501886822976 0.552872905239819 0.575552960829275 0.528735725333748 0.673536000041314 0.616306055966220 0.596732320262772 0.620430313847279];
c=[1.11459952996087 1.68670358870423 1.22532598107866 0.624815936271779 0.554255279167175 1.15749032120038 0.572704247243950 0.818472371403532 0.610108820878572 0.520393200082739 0.877109078448262 0.584376156817110 0.864813871234754 0.737829446874604 0.580997699895747 1.77068479618745 0.539182799387493 1.62437864878862 0.521003914004704 0.849895522917450 0.577263897904287 0.526984303503854 1.64990069405968 1.53080783202811 0.896341460688281 0.691820506571966 0.839658467823829 0.916296633939690 1.57481829415576 1.11756769475573 0.496358173351652 0.758366460593150 0.603591262006390 0.856744750071039 0.634025989346108 0.862693031299083 0.499801270339618 1.31880150505211 0.497983284511088 0.955339233571990 0.607304623078370 0.720711362625385 0.662375530565266 0.794992908912330 1.27508484531957 0.681838541650462 1.39432785905121 0.921767072964069 0.732218886357660 1.62092196497150 1.05716708049553 0.921938203224915 0.972931972055981 0.785631875908351 0.762332383313575 0.939098232445008 0.495829657412097 0.734698073565044 0.854786553397547 0.766021749291286 0.757263163382394 0.528035422450610 1.76412942257156 0.480878637061892 0.779087865119777 0.444875526901451 0.702140015667567 0.475393228042059 0.768312696667354 0.638589873668904 1.27460847277030 1.48937825107580 0.495231950051789 0.493444405935982 0.504732624749794 0.631618660777873 1.27292293987335 0.628781242055882 0.488060785261759 0.554757947749088 1.66634519190679 0.900376834938410 1.10921191147181 1.66756865514712 0.574270568683960 1.70204892135356 0.920784050984837 0.538263886964218 1.76503134659234 0.628734987014323 0.595634664706628 0.509007492420166 0.621106010756416 0.860695885662515 1.58470245060019 0.742921218056206 0.756422431551545 0.640398131277412 1.29779726790267 0.523270699017041];
figure
hold on
plot(a)
plot(b)
plot(c)
legend(["a","b","c"])
Sadiq Akbar
am 15 Jan. 2023
Bearbeitet: Sadiq Akbar
am 15 Jan. 2023
the cyclist
am 15 Jan. 2023
Can you explain why it is a problem that b>c "after about 80", but it is not a problem that b(5) > c(5)?
How should the exact location to start fixing the problem be selected? How do we figure out "about 80"?
It might be helpful for you to explain the reasoning behind changing this vectors, because the rules are very strange.
Sadiq Akbar
am 15 Jan. 2023
dpb
am 15 Jan. 2023
There are values of c that are less than b way back before index 20, not ony at the higher indices.
What's the justification for the uniformly decreasing sequence between two sets of indices; certainly the waveforms presented don't show any such patterns.
My recommendation would be to simply adjust each of b to be greater than a at each point by some fraction of the difference or randomized amount, then repeat that for the c trace relative the adjusted b (in the cases b needs adjusting, too).
Sadiq Akbar
am 16 Jan. 2023
Bearbeitet: Sadiq Akbar
am 16 Jan. 2023
Sadiq Akbar
am 16 Jan. 2023
Akzeptierte Antwort
Weitere Antworten (1)
Sulaymon Eshkabilov
am 16 Jan. 2023
Bearbeitet: Torsten
am 16 Jan. 2023
0 Stimmen
The err in your code is with 0 in b's index that is not acceptable. Because b(0) does not exist. Which element of b vector are you try to call there? E.g 1st element, then b(1)
1 Kommentar
Sadiq Akbar
am 16 Jan. 2023
Kategorien
Mehr zu Whos finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
