Change negative values in data

5 views (last 30 days)
PureFleet on 29 Nov 2021
Commented: PureFleet on 29 Nov 2021
I have made a variable to show when my data is negative and to write NaN but I need it to show that on the original data. Any tips on how I can do this?
for a = find(invalidDataIndex == 1)
a(invalidDataIndex) = NaN

Accepted Answer

dpb on 29 Nov 2021
You're almost there, but making it more complicated than needs be...
invalidDataIndex=(windTurbineData.mean_Power_kW<0); % the result is logical array already
windTurbineData.mean_Power_kW(invalidDataIndex) = NaN; % use logical indexing
Of course, you don't even need the temporary index at all, just a logical indexing expression...
windTurbineData.mean_Power_kW(windTurbineData.mean_Power_kW<0) = NaN; % use logical indexing

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!