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 :

Interpolation lineaire dans un triangle


Sujet :

MATLAB

  1. #1
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Septembre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Burkina Faso

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Services à domicile

    Informations forums :
    Inscription : Septembre 2013
    Messages : 4
    Points : 1
    Points
    1
    Par défaut Interpolation lineaire dans un triangle
    Bonjour tout le monde, j'ai fais un programme sous MATLAB et j'ai des erreurs que je n'arrive pas a corriger. Veuillez m'aider svp:
    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
    function zi=interptri(tri,x,y,z,xi,yi)
     
    if nargin~=6
       error('Six Input Arguments Required.')
    end
    x=x( : ); % make input data into vectors
    y=y( : );
    z=z( : ).';
    xlen=length(x);
    if ~isequal(xlen,length(y),length(z))
       error('X, Y, and Z Must Have the Same Number of Elements.')
    end
    if size(tri,2)~=3 || any(tri( : )<0) || any(tri( : )>xlen)
       error('TRI Must Be a Valid Triangulation of the Data in X, Y, Z.')
    end
     
    zisiz=size(xi);
    xi=xi( : );
    yi=yi( : );
    if length(xi)~=length(yi)
       error('Xi and Yi Must Have the Same Number of Elements.')
    end
    %ti=tsearch(x,y,tri,xi,yi); % find triangle associated with each data point.
     
    % use tsearchn because tsearch is now gone
    ti=tsearchn([x y],tri,[xi yi]);
     
    tinan=isnan(ti);  % True for xi, yi outside the convex hull
    ti(tinan)=1;      % point nan points to triangle one for now
    tri=tri(ti,: );    % keep only those triangles where xi and yi exist
     
    x1=x(tri( :,1));   % x data at vertices
    x2=x(tri( :,2));
    x3=x(tri( :,3));
    y1=y(tri( :,1));   % y data at vertices
    y2=y(tri( :,2));
    y3=y(tri( :,3));
     
    A2=(x2-x1).*(y3-y1) - (x3-x1).*(y2-y1); % shape functions
    N( :,3)=((x1-xi).*(y2-yi) - (x2-xi).*(y1-yi))./A2;
    N( :,2)=((x3-xi).*(y1-yi) - (x1-xi).*(y3-yi))./A2;
    N( :,1)=((x2-xi).*(y3-yi) - (x3-xi).*(y2-yi))./A2;
    N(tinan,: )=0;           % give zero weight to nan data
    zi = sum(z(tri).*N,2);  % interpolate
    zi(tinan)=nan;          % poke in nans where needed
    zi=reshape(zi,zisiz);   % reshape output to match xi and yi input
    les erreurs indiquées sont:
    ??? Error using ==> sparse
    Index into matrix must be an integer.
    
    Error in ==> tsearchn at 57
        t = tsrchnmx(x',tri,xi',2);
    
    Error in ==> interptri at 47
    ti=tsearchn([x y],tri,[xi yi]);

    Merci pour votre aide!!

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 302
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 302
    Points : 53 165
    Points
    53 165
    Par défaut
    Citation Envoyé par haroukiki Voir le message
    j'ai fais un programme sous MATLAB
    Mais bien sûr... Linearly Interpolate Triangulation by Duane Hanselman
    Ingénieur indépendant en mécatronique - Conseil, conception et formation
    • Conception mécanique (Autodesk Fusion 360)
    • Impression 3D (Ultimaker)
    • Développement informatique (Python, MATLAB, C)
    • Programmation de microcontrôleur (Microchip PIC, ESP32, Raspberry Pi, Arduino…)

    « J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" » (Saint Huck)

Discussions similaires

  1. Probleme d'interpolation lineaire
    Par Pelagos dans le forum Fortran
    Réponses: 2
    Dernier message: 06/01/2010, 17h18
  2. Droite dans un triangle a partir d'une condition effectuée
    Par wystan dans le forum Mathématiques
    Réponses: 7
    Dernier message: 18/12/2008, 18h45
  3. Aire max du rectangle inscrit dans un triangle
    Par gadalla dans le forum Pascal
    Réponses: 8
    Dernier message: 05/06/2007, 19h58
  4. Point dans un triangle ou quadrangle ?
    Par sunshine33 dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 13/07/2006, 14h13
  5. [GEOMETRIE] calcul de distance dans un triangle
    Par gronaze dans le forum Mathématiques
    Réponses: 10
    Dernier message: 29/06/2006, 10h04

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