subs Command
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Is it possible to make an array in a function then substitute a certain element to another element. I have a beam equation with certain forces on different parts. So I created a variable for the length and am given an expression for the whole beam. So I split the equation into multiple parts and now want to evaluate each piece through different lengths. Any help would be appreciated. Thanks
0 commentaires
Réponse acceptée
Geoff
le 3 Fév 2012
From your description I gather that you want to swap out a range of values from an array into new indices within that array. You can modify values in a range by simply passing that range as a subscript on the left and passing new values (the same length) on the right...
Let's say I have the array:
x = 1:20
I can swap 5 elements from either end like this:
x([1:5 15:20]) = x([15:20 1:5])
Or duplicate sections
x(1:4) = x(5:8)
Or just mess it up
x([5 9 20 13:16]) = x([1 4 7 10 11 18 19 20])
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!