V shape star pattern in MATLAB

MATLAB Program:


x=input('Enter the number:');
y=[];%output
for i=1:x
    for j=1:(2*x-1)
        if(i==j || i+j==2*x)
            y(i,j)='*';
        end
    end
end
z=char(y);
disp(z);


OUTPUT:

No comments