function result = integrera(f,I,n,str)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
x = linspace(I(1), I(2), n+1);
dx = (I(2)-I(1))/n;

switch str
   
    case "Left"
        %disp("Left Riemann Sum")
        result = sum(f(x(1:n)).*dx);
    case "Right"
        %disp("Right Riemann Sum")
        result = sum(f(x(2:n+1)).*dx);
    case "Middle"
        %disp("Midpoint Rule")
        result = sum(f( x(1:n)+dx/2 ).*dx);
    case "Trapezoid"
        %disp("Trapezoid Rule")
        %sum(f(x(1:n)).*dx + dx.*(f(x(2:n+1))-f(x(1:n)))./2)
        result = sum( (f(x(1:n)) + f(x(2:n+1))).*(dx/2) );
    otherwise
        disp("Ogiltig metod :(")
end       


end

