How to evaluate two variable function...?
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Maruti Patil
 il 10 Ott 2015
  
    
    
    
    
    Risposto: Star Strider
      
      
 il 10 Ott 2015
            f=@(x1,x2) 2*x1^2+x2^2+2*x1*x2+x1-x2;
x1=0; x2=1;
X=[x1;x2];
How to evaluate function using vector X..?
f(X) is not working.
0 Commenti
Risposta accettata
  Star Strider
      
      
 il 10 Ott 2015
        To evaluate it with a matrix input, each of the variables has to refer to a column (or row) of that matrix.
You have defined ‘X’ as a column vector, so this syntax for your function works with it:
f=@(x) 2*x(1,:).^2 + x(2,:).^2 + 2*x(1,:).*x(2,:) + x(1,:) - x(2,:);
x1=0; x2=1;
X=[x1;x2];
Result_1 = f(X)
X2 = randi(9, 2, 5);                        % Create Input Data Matrix
Result_2 = f(X2)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!