function [] = drawtens2d(I)

%Input I shold be an nxnx2x2 array
%This function will draw the ellipses
%I(i,j,:,:) i+j<+n+1
%in a triangle





%resolution
resol=100;

[n,~,d,~]=size(I);
temp=zeros(d);

%shrinkfactor (to avoid intersecting ellipses) 
sf=5*n;

%meshsize
h=1/(n-1);

for i=1:n
    for j=1:n+1-i
        temp(:,:)=I(i,j,:,:);
        phi=linspace(0,2*pi,resol);
        ps=temp*[cos(phi);sin(phi)]/sf;
        x=(i-1)*h+ps(1,:);
        y=(j-1)*h+ps(2,:);
        patch(x,y,'b')
    end
end
hold on;
plot([0 1 0 0],[0 0 1 0],'k');
                       

%white background
set(gcf,'color','w');


axis equal
axis off
axis tight

end