Trying to change columns in a Matrix
Mostra commenti meno recenti
So lets say I have an array = [1 2 3 4; 3 3 4 5; 4 4 4 7], a 3 by 4 matrix. I want to change a certain column for a specified row. so lets say I want to change the columns 1,3,2 of the corresponding rows 1,2,3. All of the columns im changing for the corresponding rows will be changed to a value of 10. So my ideal answer when printing out the new matrix should be [10 2 3 4; 3 3 10 5; 4 10 4 7]. I'm trying to not use any loops to save on run time. And I've tried doing something like this: array(1:3, [1,3,2]) = 10. But I got the result [10 10 10 4; 10 10 10 5; 10 10 10 7]. which is not the answer I want. Is it possible to do this without using any loops. Any help would be appreciated thanks!!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!