X_o = input('X_o: '); % Initial Point on X-coordinate
Y_o = input('Y_o: '); % Initial Point on Y-coordinate
X_1 = input('X_1: '); % Final Point on X-coordinate
Y_1 = input('Y_1: '); % Final Point on Y-coordinate
dx = abs(X_1-X_o); % Difference between points in X-axis
dy = abs(Y_1-Y_o); % Difference between points in Y-axis
n = max(dx,dy); % To select the steps
X(1)=X_o; Y(1)=Y_o; j=1;
for i = 0:1:n
if (X_1 == X)&(Y_1 == Y)
break
end
j =j+1;
X(j)= X(j-1) + (dx/n);
Y(j)= Y(j-1) + (dy/n);
end
plot(round(X),round(Y));
legend('DDA Line');
title('DDA Algorithm')
xlabel('X Axis'); %labeling the X axis
ylabel('Y Axis'); %labeling the Y axis
Cite As
Jash (2024). DDDA (https://www.mathworks.com/matlabcentral/fileexchange/155392-ddda), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2023b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |