MATLAB: How i can find the DTFT of sequence without using fft inbuilt function

https://blogs.mathworks.com/steve/2010/03/15/the-dft-and-the-dtft-mathjax/?s_tid=srchtitleMATLAB

i am trying this code,
clc; clear; close all;
n = 0:1:100;
x = ((n >= 0) - (n >= 5));
stem(n, x);
len = length(x);
X = zeros(1, len);
for w = 0:2*pi*len
for n = 0:len
X(w+1) = X(w+1) + x(w+1)*exp(-1j*w*n);
end
end

Best Answer

w=-pi:0.01:pi;
n=0:50;
x=[1 2 3 4];
for i=1:length(w);
X(i)=0;
for k=1:length(x);
X(i)=X(i)+x(k).*exp(-j.*w(i).*n(k));
end
end
plot(w,X);
title('DTFT');