Change values in matrix if it matches a tableObtaining matrix and column matches“Find and replace” from a matrix MATLABTrim Binary Matrix in MatLabresizing matrix and matching dataSum of groups of four in a matrixSelect a row matrix of values based on searchUsing a Matrix to Populate Every Other Value in a Columnfilling a zero matrix corresponding to row and column numbers2 values of different matrices match. Now change another value in same rowChanging data diagonally in matrix based on formula and table

Who or what determines if a curse is valid or not?

Why does a tetrahedral molecule like methane have a dipole moment of zero?

When a ball on a rope swings in a circle, is there both centripetal force and tension force?

How should I interpret a promising preprint that was never published in a peer-reviewed journal?

Parser for STL stereolithography data files

Somebody hacked my clock

Do pedestrians imitate automotive traffic?

Are there any satellites in geosynchronous but not geostationary orbits?

Will copper pour help on my single-layer PCB?

What is the function of "mal" in saying "Das nenn ich mal ein X"?

Did Hitler say this quote about homeschooling?

How do you name this compound using IUPAC system (including steps)?

How do you send money when you're not sure it's not a scam?

Last-minute canceled work-trip means I'll lose thousands of dollars on planned vacation

Three Subway Escalators

Does unblocking power bar outlets through short extension cords increase fire risk?

What is the intuition for higher homotopy groups not vanishing?

Improving an O(N^2) function (all entities iterating over all other entities)

I want light controlled by one switch, not two

Do higher dimensions have axes?

Discontinuous Tube visualization

Applying for jobs with an obvious scar

To what extent does asymmetric cryptography secure bitcoin transactions?

Are there foods that astronauts are explicitly never allowed to eat?



Change values in matrix if it matches a table


Obtaining matrix and column matches“Find and replace” from a matrix MATLABTrim Binary Matrix in MatLabresizing matrix and matching dataSum of groups of four in a matrixSelect a row matrix of values based on searchUsing a Matrix to Populate Every Other Value in a Columnfilling a zero matrix corresponding to row and column numbers2 values of different matrices match. Now change another value in same rowChanging data diagonally in matrix based on formula and table






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Hello I'm trying to do the following:



This is my table :



1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25


and I have a matrix [25,1].



I want to do the following: if the values in first and last columns match the numbers in the matrix, change the value to "99".



So the output should be this:



99
2
3
4
99
99
7
8
9
99
99
12
13
14
99
99
17
18
19
99
99
22
23
24
99


This is my attempt:



NT = zeros (x*y:1);
NT(:,1) = 1:x*y;

for i = 1:x*y
for j = 1
if NT(i,j) == x1(i,j)
NT(i,j) = 99;

end
end
end









share|improve this question






























    0















    Hello I'm trying to do the following:



    This is my table :



    1 2 3 4 5
    6 7 8 9 10
    11 12 13 14 15
    16 17 18 19 20
    21 22 23 24 25


    and I have a matrix [25,1].



    I want to do the following: if the values in first and last columns match the numbers in the matrix, change the value to "99".



    So the output should be this:



    99
    2
    3
    4
    99
    99
    7
    8
    9
    99
    99
    12
    13
    14
    99
    99
    17
    18
    19
    99
    99
    22
    23
    24
    99


    This is my attempt:



    NT = zeros (x*y:1);
    NT(:,1) = 1:x*y;

    for i = 1:x*y
    for j = 1
    if NT(i,j) == x1(i,j)
    NT(i,j) = 99;

    end
    end
    end









    share|improve this question


























      0












      0








      0








      Hello I'm trying to do the following:



      This is my table :



      1 2 3 4 5
      6 7 8 9 10
      11 12 13 14 15
      16 17 18 19 20
      21 22 23 24 25


      and I have a matrix [25,1].



      I want to do the following: if the values in first and last columns match the numbers in the matrix, change the value to "99".



      So the output should be this:



      99
      2
      3
      4
      99
      99
      7
      8
      9
      99
      99
      12
      13
      14
      99
      99
      17
      18
      19
      99
      99
      22
      23
      24
      99


      This is my attempt:



      NT = zeros (x*y:1);
      NT(:,1) = 1:x*y;

      for i = 1:x*y
      for j = 1
      if NT(i,j) == x1(i,j)
      NT(i,j) = 99;

      end
      end
      end









      share|improve this question
















      Hello I'm trying to do the following:



      This is my table :



      1 2 3 4 5
      6 7 8 9 10
      11 12 13 14 15
      16 17 18 19 20
      21 22 23 24 25


      and I have a matrix [25,1].



      I want to do the following: if the values in first and last columns match the numbers in the matrix, change the value to "99".



      So the output should be this:



      99
      2
      3
      4
      99
      99
      7
      8
      9
      99
      99
      12
      13
      14
      99
      99
      17
      18
      19
      99
      99
      22
      23
      24
      99


      This is my attempt:



      NT = zeros (x*y:1);
      NT(:,1) = 1:x*y;

      for i = 1:x*y
      for j = 1
      if NT(i,j) == x1(i,j)
      NT(i,j) = 99;

      end
      end
      end






      matlab






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 16:09









      beaker

      13.3k2 gold badges23 silver badges41 bronze badges




      13.3k2 gold badges23 silver badges41 bronze badges










      asked Mar 26 at 11:35









      user11234070user11234070

      143 bronze badges




      143 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          This can be done very easily with ismember. Let



          A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20; 21 22 23 24 25];
          B = (1:25).';
          new_value = 99;


          Then



          B(ismember(B, A(:, [1 end]))) = new_value;


          gives



          B =
          99
          2
          3
          4
          99
          99
          7
          8
          9
          99
          99
          12
          13
          14
          99
          99
          17
          18
          19
          99
          99
          22
          23
          24
          99





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55356187%2fchange-values-in-matrix-if-it-matches-a-table%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            This can be done very easily with ismember. Let



            A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20; 21 22 23 24 25];
            B = (1:25).';
            new_value = 99;


            Then



            B(ismember(B, A(:, [1 end]))) = new_value;


            gives



            B =
            99
            2
            3
            4
            99
            99
            7
            8
            9
            99
            99
            12
            13
            14
            99
            99
            17
            18
            19
            99
            99
            22
            23
            24
            99





            share|improve this answer



























              1














              This can be done very easily with ismember. Let



              A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20; 21 22 23 24 25];
              B = (1:25).';
              new_value = 99;


              Then



              B(ismember(B, A(:, [1 end]))) = new_value;


              gives



              B =
              99
              2
              3
              4
              99
              99
              7
              8
              9
              99
              99
              12
              13
              14
              99
              99
              17
              18
              19
              99
              99
              22
              23
              24
              99





              share|improve this answer

























                1












                1








                1







                This can be done very easily with ismember. Let



                A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20; 21 22 23 24 25];
                B = (1:25).';
                new_value = 99;


                Then



                B(ismember(B, A(:, [1 end]))) = new_value;


                gives



                B =
                99
                2
                3
                4
                99
                99
                7
                8
                9
                99
                99
                12
                13
                14
                99
                99
                17
                18
                19
                99
                99
                22
                23
                24
                99





                share|improve this answer













                This can be done very easily with ismember. Let



                A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20; 21 22 23 24 25];
                B = (1:25).';
                new_value = 99;


                Then



                B(ismember(B, A(:, [1 end]))) = new_value;


                gives



                B =
                99
                2
                3
                4
                99
                99
                7
                8
                9
                99
                99
                12
                13
                14
                99
                99
                17
                18
                19
                99
                99
                22
                23
                24
                99






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 11:39









                Luis MendoLuis Mendo

                96k11 gold badges58 silver badges126 bronze badges




                96k11 gold badges58 silver badges126 bronze badges
















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55356187%2fchange-values-in-matrix-if-it-matches-a-table%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript