Compare Two Data Sets: How to Compare Only the non-NaN rows Together?

3 vues (au cours des 30 derniers jours)
BN
BN le 19 Déc 2019
Hello all,
I have a general question. if I have 2 data sets of real data and predicted data, which in those column A is date and column B is value, is it possible to compare them when I have some NaN values in real data set?
I thought it would be easy by index using isnan but if I ignore NaN rows in reading data sets how to recognize related date value from predicted data sets? in fact, I want to compare only the non-NaN rows together.

Réponses (1)

Jakob B. Nielsen
Jakob B. Nielsen le 19 Déc 2019
Question one: how can you have predicted data, if you have no real data? :D
Anyways. Does your predicted data for those instances where you have no real data matter? I would simply remove them from the data set before comparing... (Of course, save the whole thing separately before deleting entries in a 'work file'...)
Otherwise, you can totally do what you want with isnan function. Just keep all your data in the same matlab table in the workspace, and then if there is a NaN value in column 4, skip for that index.
rows=size(Data,1);
for i=1:rows
if isnan(Data(i,4))
%do nothing
else
%do your comparison
end
end

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by