Assign a value to a matrix element defined as a variable
Afficher commentaires plus anciens
Hi all,
Is it possible to assign values (variables) to elements in a matrix that is defined as a function handle?
For example:
prop1 = zeros(2);
prop1(:,1) = 1;
prop1(:,2) = 2;
prop1
prop2 = @(x) [0 0;
0 0]
prop2(:,2) = @(x) x(2)
I would like to assign variables to prop2 as I did to prop1.
2 commentaires
Geovane Gomes
le 17 Juin 2023
Modifié(e) : Geovane Gomes
le 17 Juin 2023
Steven Lord
le 17 Juin 2023
Use repmat or repelem.
Réponse acceptée
Plus de réponses (1)
Voss
le 17 Juin 2023
prop = @(x)[x([repmat([1 3],11,1); repmat([2 4],12,1)]) zeros(23,2)];
1 commentaire
Geovane Gomes
le 17 Juin 2023
Catégories
En savoir plus sur Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!