how to get the final shape of a function after you got the variables?

I have this function: f1=[-3*X(1)+X(2)+X(2).^3; -X(2)-X(3)]; I if X(1)=4;X(2)=3...
i want to evaluate f1 at these value, how to do this?

Réponses (1)

X = [1 2 3]; % sample values X(1) = 1, X(2) = 2, X(3) = 3;
% evaluate function for these values
f1= [-3*X(1)+X(2)+X(2).^3; -X(2)-X(3)];

3 commentaires

I have to write the equations f1= [-3*X(1)+X(2)+X(2).^3; -X(2)-X(3)]; at the beginning and do some calculations and the evaluate the function
I do not want to re-write it.
Define a function
f1= @(X) [-3*X(1)+X(2)+X(2).^3; -X(2)-X(3)];
And evaluate
X = [1 2 3];
f1(X)
X(1) ... is symbolic and it does not run well,

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Question posée :

le 16 Sep 2015

Commenté :

le 16 Sep 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by