I have created a code but my code only seems to plot (x,y) variable :(( sorry I just started coding excuse my mistakes
choice = menu('Select one', '(1) Start', ' (2) Reset', '(3) Quit', '(0) Location');
if choice==1
clear;
clear all;
clc;
m=10;
for n = 1:m-1;
if n == 1;
xn = input('Input Direction: ');
fprintf('\n');
yn = input('Input Distance: ');
fprintf('\n');
x = [xn];
y = [yn];
fprintf('%d \n\n %f', x, y);
fprintf('\n\n');
plot(x,y,'-o','MarkerEdgeColor','red');
else
xn = input('Input Direction: ');
fprintf('\n');
yn = input('Input Distance: ');
fprintf('\n');
xadd = x(n-1);
yadd = y(n-1);
x = [x xn+xadd];
y = [y yn+yadd];
fprintf('\n\n');
xor = 0;
line([-max(x),max(x)],[xor,xor]);
hold on
plot([0 0],[-max(y) max(y)]);
hold on
plot(x,y,'-o','MarkerEdgeColor','red');
grid on;
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
end
end
fprintf('here are your values of x and y\n')
x
fprintf('\n');
y
elseif choice==2
clear;
clear all;
clc;
m=5;
for n = 1:m-1;
if n == 1;
xn = input('Input Direction: ');
fprintf('\n');
yn = input('Input Distance: ');
fprintf('\n');
x = [xn];
y = [yn];
fprintf('%d \n\n %f', x, y);
fprintf('\n\n');
plot(x,y,'-o','MarkerEdgeColor','red');
else
xn = input('Input Direction: ');
fprintf('\n');
yn = input('Input Distance: ');
fprintf('\n');
xadd = x(n-1);
yadd = y(n-1);
x = [x xn+xadd];
y = [y yn+yadd];
fprintf('\n\n');
xor = 0;
line([-max(x),max(x)],[xor,xor]);
hold on
plot([0 0],[-max(y) max(y)]);
hold on
plot(x,y,'-o','MarkerEdgeColor','red');
grid on;
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
end
end
fprintf('here are your values of x and y\n')
x
fprintf('\n');
y
elseif choice==3
disp = ('Normal program termination. Goodbye!')
else
plot(choice==1,'-o','MarkerEdgeColor','red');
end