Assign a value to a matrix element defined as a variable
Ältere Kommentare anzeigen
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 Kommentare
Geovane Gomes
am 17 Jun. 2023
Bearbeitet: Geovane Gomes
am 17 Jun. 2023
Steven Lord
am 17 Jun. 2023
Use repmat or repelem.
Akzeptierte Antwort
Weitere Antworten (1)
Voss
am 17 Jun. 2023
prop = @(x)[x([repmat([1 3],11,1); repmat([2 4],12,1)]) zeros(23,2)];
1 Kommentar
Geovane Gomes
am 17 Jun. 2023
Kategorien
Mehr zu Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!