Assign a value to a matrix element defined as a variable
Mostrar comentarios más antiguos
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 comentarios
Geovane Gomes
el 17 de Jun. de 2023
Editada: Geovane Gomes
el 17 de Jun. de 2023
Steven Lord
el 17 de Jun. de 2023
Use repmat or repelem.
Respuesta aceptada
Más respuestas (1)
Voss
el 17 de Jun. de 2023
prop = @(x)[x([repmat([1 3],11,1); repmat([2 4],12,1)]) zeros(23,2)];
1 comentario
Geovane Gomes
el 17 de Jun. de 2023
Categorías
Más información sobre Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!