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?

Respuestas (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 comentarios

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,

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 16 de Sept. de 2015

Comentada:

el 16 de Sept. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by