- #1

- 47

- 0

## Main Question or Discussion Point

Hi,

I am trying to put a eqn in a function. So i can just type this function file name into another to find out the answers. This is what i got from the question:

function y = f1(x) %required function name

y=f1(x)

x=(x1,x2)

f1(x1,x2)=x1*5+x2*3

what i did :

function y = f1(x)

x=[x1,x2];

y=x1*5+x2*3;

end

It said Error in ==> f1 at 2 x = [x1,x2];

what im thinking is y is output and x is input here. So i declare the x to be x1,x2 and then declare the eqn of y. What should i do to fix this out?

Thanks

I am trying to put a eqn in a function. So i can just type this function file name into another to find out the answers. This is what i got from the question:

function y = f1(x) %required function name

y=f1(x)

x=(x1,x2)

f1(x1,x2)=x1*5+x2*3

what i did :

function y = f1(x)

x=[x1,x2];

y=x1*5+x2*3;

end

It said Error in ==> f1 at 2 x = [x1,x2];

what im thinking is y is output and x is input here. So i declare the x to be x1,x2 and then declare the eqn of y. What should i do to fix this out?

Thanks