logical indexing for dlarrays
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I noticed that when I perform logical indexing on a formatted dlarray, it looses its format. Does anyone has an idea why this is and how I could workaround this? I want to do automatic differentiation afterwards, so I guess when the format is removed, that might be not possible.
Any help would be appreciated!
x = dlarray([1, 2, 3], "CB")
index = [true, false, true];
xNew = x(index)
0 Commenti
Risposte (1)
Prince Kumar
il 20 Gen 2022
Modificato: Prince Kumar
il 20 Gen 2022
Hi,
This is the intended behaviour once you index "dlarray".
Possible workaround is to re-apply the format. Here is the way to do it :
x = dlarray([1, 2, 3, 4, 5], "CB");
index = [true, false, true];
xNew = x(index);
xNew = dlarray(xNew, "CB")
dims(xNew)
As you can see now, xNew will have the format as "CB".
Hope this helps.
Vedere anche
Categorie
Scopri di più su Install Products in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!