How to generate all the possible data points in this 2D triangle?
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hi,

I have a blue triangle in a 2-D V-S space. 
How can I know the [s v] values of all the possible points within the blue triangle area?
4 Commenti
  Torsten
      
      
 il 18 Gen 2023
				s >=0
v >= 0
s + v <= 1
The blue region is characterized as the set of pairs (s,v) that satisfy all three constraints.
Never heard of linear programming ? Simplex algorithm ? Optimization under constraints ? Linprog ?
Risposta accettata
  KSSV
      
      
 il 18 Gen 2023
        P = [0 0 ; 0 1 ; 1 0] ;  % vertices of triangle 
m = 20 ; n = 20 ; 
x = linspace(min(P(:,1)),max(P(:,1)),m) ;
y = linspace(min(P(:,2)),max(P(:,2)),n) ;
[X,Y] = meshgrid(x,y) ; 
idx = inpolygon(X,Y,P(:,1),P(:,2)) ;
patch(P(:,1),P(:,2),'b')
hold on
plot(X(idx),Y(idx),'.r')
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Creating, Deleting, and Querying Graphics Objects in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

