I have already declared some variable values as (for example):(adsbygoogle = window.adsbygoogle || []).push({});

a = 2

b = 3

Now I want to declare a function like:

f(x) = x + a - b

I will be optimizing w.r.t. x later, so I don't want to enter it as f(x,a,b)

(or is it possible to oiptimise w.r.t. just one of the variables?)

I tried

f = inline('x+a-b','x')

but then when I tried to evaluate it, it didn't have values for a and b (even though they were declared before!), so caused an error.

Any ideas? (other than defining the function with a and b replaced by value, because this won't allow me to change a and b later)

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# (Should be) Simple function declarations in Matlab

Loading...

Similar Threads - Should Simple function | Date |
---|---|

Should I get Sage? | Apr 2, 2014 |

Matlab: value non-zero but it should | Oct 27, 2012 |

How should I draw a simple plot? | May 2, 2012 |

Latex Should I accept the project? | May 16, 2011 |

How Much Mathematical Background Should We Acquire When Studying General Relativity? | Nov 16, 2006 |

**Physics Forums - The Fusion of Science and Community**