samedi 25 mars 2017

Using NaN in if and interp1 commands

I got the problems when i use ISNAN and i had to use the codes under the this text:

I have 6 values and some values are NaN. If interp1 command finds the final value as NaN for giving ' c' value, MATLAB must give me error message.

a=[1 2 3 4 5 6];
b=[10 15 20 NaN NaN NaN];
c=[1.5 4 3.5 4.5 5.1 5.9];
for g=1:1:numel(a)
if interp1(a,b,c(g))==NaN;
        disp('There is a mistake here')
   end
end

But MATLAB does't run this command with NaN values.

*In interp1 at 178
Warning: NaN found in Y, interpolation at undefined values
     will result in undefined values.* 

How can i achieve this problem? How can i use NaN values in interp1 and if command?

Thanks

Aucun commentaire:

Enregistrer un commentaire