How to plot a shape away from the x and y axis?

2 Ansichten (letzte 30 Tage)
Samy Ben Thabet
Samy Ben Thabet am 10 Okt. 2018
Bearbeitet: jonas am 10 Okt. 2018
Hi,
I want to plot shapes but I don't want them to be on the axis (I don't want to remove the axis though).
Here is my program: h=input('What shape do you want?:','s'); a=input('The length of a side is (m):'); if strcmp(h, 'square') plot([0 0 a a 0],[0 a a 0 0],'r','LineWidth',3) end

Akzeptierte Antwort

jonas
jonas am 10 Okt. 2018
Bearbeitet: jonas am 10 Okt. 2018
Just adjust the axes limits
h=input('What shape do you want?:','s');
a=input('The length of a side is (m):');
if strcmp(h, 'square')
plot([0 0 a a 0],[0 a a 0 0],'r','LineWidth',3)
xlim([-a 2*a]);
ylim([-a 2*a]);
end

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by