create a plot where there is a y axis the size of referenced length and x axis of referenced length in matlab

main.m
% Create a plot with y-axis of length 10 and x-axis of length 5
yLength = 10;
xLength = 5;

plot([0 xLength], [0 0], 'k-'); % x-axis line
hold on;
plot([0 0], [0 yLength], 'k-'); % y-axis line

axis([-1 xLength+1 -1 yLength+1]); % Set axis limits
axis equal; % Make the aspect ratio of the plot box equal

xlabel('X-axis');
ylabel('Y-axis');
title('Plot with Referenced Length for X and Y Axis');

hold off;
408 chars
17 lines

This code will create a plot in MATLAB where the y-axis is of length 10 units and the x-axis is of length 5 units.

related categories

gistlibby LogSnag