How to access elements in numpy.array without converting the array?
Ältere Kommentare anzeigen
Hello all,
I'm using an outofprocess python enviornment and would like to access individual or a set of elements in a numpy array without converting it. For example.
NP = py.importlib.import_module('numpy');
x = NP.array([1 3 5 7 9 11]);
now I would like to change x(2) to 0, this is what I do now and is clearly not efficient for very large arrays in a for loop for example.
tmp = double(x);
tmp(2) = 0;
x = NP.array(tmp);
my ultimate goal is to be able to take change a set of elements eg. 3:4, or 2:2:6
Thank you for your help
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!