2017-02-26 8 views
0

Ich habe 4 Vektoren, erste drei sind komplexe Zahlen und 4. ist eine Summation von ihnen.Färbung Köcher Vektoren in Matlab

Ich zeichne sie mit Köcher erfolgreich, aber ich muss 4. als rot färben. Wie kann ich nur den 4. zu rot färben?

% vectors I want to plot as rows (XSTART, YSTART) (XDIR, YDIR) 
rays = [ 
    0 0 real(X1) imag(X1) ; 
    0 0 real(X2) imag(X2) ; 
    0 0 real(X3) imag(X3) ; 
    0 0 real(SUM) imag(SUM) ; 
] ; 

% quiver plot 
quiver(rays(:,1), rays(:,2), rays(:,3), rays(:,4)); 

% set interval 
axis([-30 30 -30 30]); 

oder soll ich plotv verwenden? https://www.mathworks.com/help/nnet/ref/plotv.html

Antwort

1

The handle durch quiver Funktion zurückgegeben erlaubt nicht, um jedes einzelne Element für den Zugriff auf seine Eigenschaften zu verändern, in diesem Fall die Farbe.

Eine mögliche Arbeit um, wenn auch nicht genau elegant, könnte sein:

  • Grundstück der Köcher für die ganze Reihe von Daten
  • von den Achsen entfernen die u, v, x und y Daten das Element möchten Sie hold on
  • Grundstück wieder die quiver für die ganze Reihe von Daten
  • 012.351 legen Sie die Farbe
  • ändern
  • Entfernen von den Achsen der u, v, x und y Daten des Elements wollen Sie nicht die Farbe

eine mögliche Implementierung des vorgeschlagenen Ansatzes

  • die gewünschte Farbe auf die remainig Artikel ändern sein könnte:

    % Generate some data 
    rays = [ 
        0 0 rand-0.5 rand-0.5 ; 
        0 0 rand-0.5 rand-0.5 ; 
        0 0 rand-0.5 rand-0.5 ; 
    ] ; 
    rays(4,:)=sum(rays) 
    
    % Plot the quiver for the whole matrix (to be used to check the results 
    figure 
    h_orig=quiver(rays(:,1), rays(:,2), rays(:,3), rays(:,4)); 
    grid minor 
    % Plot the quiver for the whole matrix 
    figure 
    % Plot the quiver for the whole set of data 
    h0=quiver(rays(:,1), rays(:,2), rays(:,3), rays(:,4)); 
    % Get the u, v, x, y data 
    u=get(h0,'udata') 
    v=get(h0,'vdata') 
    x=get(h0,'xdata') 
    y=get(h0,'ydata') 
    % Delete the data of the last element 
    set(h0,'udata',u(1:end-1),'vdata',v(1:end-1),'xdata', ... 
        x(1:end-1),'ydata',y(1:end-1)) 
    % Set hold on 
    hold on 
    % Plot again the quiver for the whole set of data 
    h0=quiver(rays(:,1), rays(:,2), rays(:,3), rays(:,4)); 
    % Delete the u, v, x, y data of the element you do not want to change the 
    % colour 
    set(h0,'udata',u(end),'vdata',v(end),'xdata', ... 
        x(end),'ydata',y(end)) 
    % Set the desired colour to the remaining object 
    h0.Color='r' 
    grid minor 
    

    enter image description here

    Hope this er lps,

    Qapla '