Exclude the NaN, 0, empty and Inf values from the analysis.
Ältere Kommentare anzeigen
When calculating the PE value, I would like it not to calculate when Ia_future = 0, Nan or Inf.
I believe the way I did it, it's still calculating. Because some PE values are still Inf.
Or if there was some way to exclude those values. The problem is that I need to plot a (t,PE) graphic and if I exclude some PE values the two will have different dimensions and I will not be able to analyze the graph..
for n = 4:size(t,1)
X = [Ia(n-1,1) Ia(n-2,1) ; Ia(n-2,1) Ia(n-3,1)];
future = [Ia(n,1) ; Ia(n-1,1)];
C = X\future;
Ia_future(n,1) = C(1,1)*Ia(n,1)+C(2,1)*Ia(n-1,1);
if (isnan(Ia_future(n, 1)) || isinf(Ia_future(n,1) || isempty(Ia_future(n,1) || Ia_future(n,1)==0))) %|| %(isnan(p(n, 1)) || p(n, 1) == 0)
continue
end
PE(n,1)=(Ia(n,1)+Ia_future(n,1))/(2000/5);
end
Akzeptierte Antwort
Weitere Antworten (1)
Is this helpful:
data = [0, 9, inf, NaN, 42];
mask = (data ~= 0) & isfinite(data)
extractedData = data(mask)
Using isfinite() takes the place/combines both ~isinf() and ~isnan() all into one simple function.
1 Kommentar
Luccas S.
am 11 Feb. 2022
Kategorien
Mehr zu Logical 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!