Que hacer cuando aparece un dato discreto NaN

10 ビュー (過去 30 日間)
Guillermo Soriano
Guillermo Soriano 2025 年 2 月 5 日
コメント済み: Guillermo Soriano 2025 年 2 月 6 日
Buenos dias
tengo ese codigo:
[za,Kea,Vea] = Prucom;
%[z_A,z_B,z_C,z_D,z_E,Ke] = JUDP_t;
z1(k) = za; %za;
Ke(k) = Kea ; %Kea;
Ve(k) = Vea;
vsx(k) = Ve(k)*nay*sin(Ke(k)*pi/180);
vsy(k) = Ve(k)*nay*cos(Ke(k)*pi/180);
datos discretos za, Kea y Vea son captutrados por la funcion Prucom de un UDP. Algunas veces en lugar de un valor aparece
NaN y las siguientes instrucciones interrumpen el algoritmo.
Que debo hacer para que se ignore el dato NaN y no se interrumpa proceso
  2 件のコメント
Walter Roberson
Walter Roberson 2025 年 2 月 5 日
Approximate translation:
Discrete data za, Kea and Vea are captured by the Prucom function of a UDP. Sometimes instead of a value, NaN appears and the following instructions interrupt the algorithm.What should I do so that the NaN data is ignored and the process is not interrupted?
Guillermo Soriano
Guillermo Soriano 2025 年 2 月 5 日
thank you Walter. I wroteed in spanish because the dialog was in my language.
Your translation is perfect... exactly what I asked in spanish.
Some ideas came to jump the process and therefore will not be made any correction. It is a extended kalman filter algorithm. If you have a better idea, please let me know it

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2025 年 2 月 5 日
編集済み: Walter Roberson 2025 年 2 月 5 日
In the worst case, there might be nothing you can do.
But possibly what you could do is convert your for loop into a while loop along these lines:
k = 0;
nanrun = 0;
while k <= NUMBER_OF_SAMPLES_TO_READ
[za,Kea,Vea] = Prucom;
if isnan(za) || isnan(Kea) || isnan(Vea);
nanrun = nanrun + 1;
if nanrun > LIMIT_ON_NUMBER_OF_NAN; break; end
continue;
else
nanrun = 0;
end
k = k + 1;
z1(k) = za; %za;
Ke(k) = Kea ; %Kea;
Ve(k) = Vea;
vsx(k) = Ve(k)*nay*sin(Ke(k)*pi/180);
vsy(k) = Ve(k)*nay*cos(Ke(k)*pi/180);
end
This reads up to NUMBER_OF_SAMPLES_TO_READ readings.
This also contains protections in case of lots of nan in a row; if there are more than LIMIT_ON_NUMBER_OF_NAN in a row then it stops reading.
  1 件のコメント
Guillermo Soriano
Guillermo Soriano 2025 年 2 月 6 日
Thank you so much Walter. The algorithm is much longer but I believe these instructions will work.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeHDF5 についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by