bonsoir,comment dessiner un cercle sous matlab svp et merci.
bonsoir,comment dessiner un cercle sous matlab svp et merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Radius = 2; [x,y,z] = cylinder(Radius,200); plot(x(1,:),y(1,:)) axis equal
Une autre solution:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 theta = 0:0.01:2*pi; rayon = 5; x = rayon*cos(theta); y = rayon*sin(theta); plot(x,y) axis equal
Bonjour.
Tu peux le faire en une instruction :
Un exemple de possibilités :
Code : Sélectionner tout - Visualiser dans une fenêtre à part plot(2*exp(2*pi*j*[0:100]/100)+1+j)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 %Tracé de cercles %================== subplot(121) theta=-pi:0.1:pi; plot(exp(j*theta)+2+2*j,'r','LineWidth',4) %Similitude : 0.5*(1+2*j) hold on plot(0.5*exp(j*pi/2)*(exp(j*theta)+2+2*j),'r','LineWidth',4) h=line([0 2;0 -1]',[0 2;0 1]'); set(h,'color','green','linewidth',2); axis square axis([-4 4 -4 4]) title('Cercles avec Similitude') grid hold off %Cercle avec une seule instruction subplot(122) plot(2*exp(2*pi*j*[0:100]/100)+1+j) axis square grid title('Cercle (avec une seule instruction)')
slt tout le monde,comment dessiner un triangle sous matlab merci bcp.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 function plot_triangle(xt,yt,length) % Triangle is defined by 3 points % point A1 : xt(1),yt(1) % point A2 : xt(2),yt(2) % point A3 : xt(3),yt(3) % length : simple case where the image is a square of length "length". % exemple : % x = [2;70;56]; % y = [100;110;45]; % plot_triangle(x,y,140) % check which point has the highest y-coordinate [c,i]=max(yt); % re-arrange the coordinates data with y(1)=yt(i) % point B1 : x(1),y(1) % point B2 : x(2),y(2) % point B3 : x(3),y(3) if i==1 x=xt; y=yt; elseif i==2 x(1)=xt(2); y(1)=yt(2); x(2)=xt(1); y(2)=yt(1); x(3)=xt(3); y(3)=yt(3); elseif i==3 x(1)=xt(3); y(1)=yt(3); x(2)=xt(1); y(2)=yt(1); x(3)=xt(2); y(3)=yt(2); end % set a black background to the image xx(1) = 0; yy(1) = length; xx(2) = length; yy(2) = length; area(xx,yy,'FaceColor','k','EdgeColor','k') hold on % plot of the first area defined by the segment [B2B1] and [B1B3] % color white xx(1) = x(2); yy(1) = y(2); xx(2) = x(1); yy(2) = y(1); xx(3) = x(3); yy(3) = y(3); area(xx,yy,'FaceColor','w','EdgeColor','k') hold on % plot of the first area defined by the segment [B2B3] % color black xx(1) = x(2); yy(1) = y(2); xx(2) = x(3); yy(2) = y(3); area(xx,yy,'FaceColor','k','EdgeColor','k') % size of the image xlim([0 length]) ylim([0 length]) box off axis off end
bonsoir,merci mais j'ai pas compris,pouvez vous étre plus clair svp.
Le code est plutôt bien commenté je trouve, qu'est-ce que tu ne comprends pas ?
Bonjour.
En jouant sur les paramètres tu mets le triangle où tu veux de dimensions que tu veux :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 clear a=1.5;b=1;c=1;d=1; theta=[0 a*pi/2 b*pi 0] plot((exp(j*theta)+c+d*j),'r','LineWidth',2) axis(3*[-1 1 -1 1]) grid
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager