-1

I want to use an integral over a vector but I will see an error for sys_eff which is " First input argument is not function handle."
I will be glad to have your guide and thanks in advance. I should mention that all vectors have the same ize as 345600.

function [ P_loss,time_eff, sys_eff ] = final( Pmpp, Pl_inv, Pl_bat_inv, Pl_bat_r )

    j=length(Pmpp);
      for t=1:j;
          P_loss(t)= Pl_inv(t) + Pl_bat_inv(t) + Pl_bat_r(t);
          time_eff(t)= P_loss(t)/Pmpp(t);
      end
    sys_eff=integral(time_eff,0,345600);
    end
Hamed
  • 193
  • 2
  • 9
  • How do you interpret the error message? It says *First input argument is not function handle.* - could it be that you are passing a variable and not a function? – Schorsch Sep 09 '14 at 14:24
  • Read the documentation for [`integral`](http://www.mathworks.com/help/matlab/ref/integral.html), it is for integrating functions. [`trapz`](http://www.mathworks.com/help/matlab/ref/trapz.html) is a numeric integration and likely what you're looking for. – sco1 Sep 09 '14 at 14:25
  • Thank you excaza :) with this function it works properly. Thanks for comment Schorsch – Hamed Sep 09 '14 at 14:42

1 Answers1

1

As from the error message, the first input you provided to the function integral (i.e. time_eff) is not a function handle, but a vector. If you want to make a numeric integral of the function use the function trapz

sys_eff=trapz(t,time_eff)

if t is your integration variable.

alexmogavero
  • 537
  • 2
  • 12