Effacer les filtres
Effacer les filtres

simple trapz function integration problem

1 vue (au cours des 30 derniers jours)
dee
dee le 3 Nov 2012
Hi all,
I have simple code to integrate the matrix using trapz. I don't want to include NaN number on the matrix in the integration, but the code just give zero value at the end.
Here is the code:
x=[1 3 4 NaN; 5 6 8 7];
for i=1:2;
for j=1:4;
if isnan(x(i,j));
y(i,j)=trapz(x(i,j));
else y(i,j)= NaN;
end;
end;
end;
Maybe anyone can help, thanks.
  1 commentaire
Gang-Gyoo
Gang-Gyoo le 4 Nov 2012
Try to use this code:
x=[1 3 4 NaN; 5 6 8 7];
s1= trapz(x(1,1:3))
s2= trapz(x(2,:))

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by