IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

Dessiner un cercle


Sujet :

MATLAB

  1. #1
    Candidat au Club
    Inscrit en
    Mai 2011
    Messages
    92
    Détails du profil
    Informations forums :
    Inscription : Mai 2011
    Messages : 92
    Points : 2
    Points
    2
    Par défaut Dessiner un cercle
    bonsoir,comment dessiner un cercle sous matlab svp et merci.

  2. #2
    Membre émérite
    Avatar de Franck Dernoncourt
    Homme Profil pro
    PhD student in AI @ MIT
    Inscrit en
    Avril 2010
    Messages
    894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : PhD student in AI @ MIT
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2010
    Messages : 894
    Points : 2 464
    Points
    2 464
    Par défaut
    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

  3. #3
    Invité
    Invité(e)
    Par défaut
    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

  4. #4
    Membre émérite
    Homme Profil pro
    Inscrit en
    Mai 2008
    Messages
    2 040
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 2 040
    Points : 2 841
    Points
    2 841
    Par défaut
    Bonjour.

    Tu peux le faire en une instruction :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    plot(2*exp(2*pi*j*[0:100]/100)+1+j)
    Un exemple de possibilités :
    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)')

  5. #5
    Candidat au Club
    Inscrit en
    Mai 2011
    Messages
    92
    Détails du profil
    Informations forums :
    Inscription : Mai 2011
    Messages : 92
    Points : 2
    Points
    2
    Par défaut dessiner un triangle sous matlab
    slt tout le monde,comment dessiner un triangle sous matlab merci bcp.

  6. #6
    Membre émérite
    Avatar de Franck Dernoncourt
    Homme Profil pro
    PhD student in AI @ MIT
    Inscrit en
    Avril 2010
    Messages
    894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : PhD student in AI @ MIT
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2010
    Messages : 894
    Points : 2 464
    Points
    2 464
    Par défaut troll ?
    Citation Envoyé par karika Voir le message
    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

  7. #7
    Candidat au Club
    Inscrit en
    Mai 2011
    Messages
    92
    Détails du profil
    Informations forums :
    Inscription : Mai 2011
    Messages : 92
    Points : 2
    Points
    2
    Par défaut tracer in triangle
    bonsoir,merci mais j'ai pas compris,pouvez vous étre plus clair svp.

  8. #8
    Membre émérite
    Avatar de Franck Dernoncourt
    Homme Profil pro
    PhD student in AI @ MIT
    Inscrit en
    Avril 2010
    Messages
    894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : PhD student in AI @ MIT
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2010
    Messages : 894
    Points : 2 464
    Points
    2 464
    Par défaut
    Le code est plutôt bien commenté je trouve, qu'est-ce que tu ne comprends pas ?

  9. #9
    Membre émérite
    Homme Profil pro
    Inscrit en
    Mai 2008
    Messages
    2 040
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 2 040
    Points : 2 841
    Points
    2 841
    Par défaut
    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

Discussions similaires

  1. demande d'aide pour dessiner un cercle
    Par nadjib2007 dans le forum C++Builder
    Réponses: 3
    Dernier message: 06/09/2007, 20h09
  2. Réponses: 10
    Dernier message: 11/04/2007, 11h14
  3. Dessiner un cercle sur une sphère ?
    Par nico_ippo dans le forum MATLAB
    Réponses: 2
    Dernier message: 15/01/2007, 17h25
  4. Réponses: 2
    Dernier message: 13/10/2004, 14h52
  5. Dessiner un cercle
    Par delire8 dans le forum DirectX
    Réponses: 7
    Dernier message: 26/07/2003, 12h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo