Using trapz for integrating with nonuniform spacing
Mostra commenti meno recenti
Hello,
I am trying to compute the loss of an inductor by using data points for time and flux data from simulation. The simulation result for time has non-uniform spacing so I am using trapz to integrate instead of using sum since dtime is varying. However, the result I get when using trapz is significantly small and not close to the expected value.
Case 1: sum - take the average value of the time steps and do the integration using sum - result is close to expected value
Ploss = (dtime/T) * ki * Bptp^(b-a)*sum( (abs(dBdt)).^a );
Case2: dtime in this case is the time step between each data point so I am trying to integrate using each time step
Ploss=(ki * Bptp^(b-a))/T*(trapz(dtime,(abs(dBdt)).^a,1))
What could I be doing wrong in case 2? I believe that case 2 is a better approach since it uses the actual time step data instead of taking the average.
Thank you.
Risposte (1)
You mustn't use "dtime" in the call to "trapz", but the actual time vector t for which the simulation gave you the corresponding vector dBdt as result.
1 Commento
Firehiwot Gurara
il 17 Nov 2022
Categorie
Scopri di più su Numerical Integration and Differentiation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!