I can't plot square or rectangle correctly
Ältere Kommentare anzeigen
x = input('enter x number:')
y = input('enter y number:')
z = input('enter widht:')
v = input('enter lenght:')
axes('NextPlot', 'add','XLim', [((-abs(x)-abs(z))+25), ((abs(x)+abs(z)+25))], 'YLim', [((-abs(y)-abs(v))+25), ((abs(y)+abs(v)+25))]);
for e = x:0.5:(abs(x)+abs(z))
plot(e, y, '*k')
pause(0.05)
end
for e = y:0.5:(abs(y)+abs(v))
plot(x,e, '*k')
pause(0.05)
end
for e = x:0.5:(abs(x)+abs(z))
plot(e,(abs(y)+abs(v)),'*k')
pause(0.05)
end
for e = y:0.5:(abs(y)+abs(v))
plot((abs(y)+abs(v)),e, '*k')
pause(0.05)
end
There is a issue with my last for-end loop. Last edge of rectangle doesn't fit correctly. Also I used 25 to see graph more clear. Can you check that. I feel like I did something wrong there too.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!