# How to write a symfun for given Y values array?

1 view (last 30 days)
sun on 19 Aug 2021
Commented: sun on 24 Aug 2021
Hi guys.
1. The temputure array A is given (Y value) in hours,
2. of course, X are uniformly distributed in hours, e.g x1 = 1, x2 = 2, x3 = 3. x4 = 4 ...
3. e.g a1 = f(x1=1), a2 = f(x2=2), a3 = f(x3=3), ...
My question is, how to write this weather vs hour function ?
Note that, 1. this funcation must be a symfun type, (f is symfun, x is sym) because I need to give this symfun into the "int" function later.
2. since this funcation will feed into "int", I think it should be able to give any Y value for given X. e.g, Y = whatever number = f(1.64), this 1.64 is a number between x1 and x2, in other words, this function is not discrete (not spikes) but a continuous. It doesnt need to be "smoothly" continuous, even straight line connected is fine.
Thank you! Walter Roberson on 19 Aug 2021
The difference between int() of a symbolic expression() compared to int() of a symfun, is:
• the result of int() of a symbolic expression is always a symbolic expression. If no integration variable is specified, then symvar() is used to find the default variable to integrate with respect to
• the result of int() of a symfun is not always a symfun. If no integration variable is specified, then the variable that is the first parameter is used as the variable to integrate with respect to. The variable that was integrated with respect to is removed from the parameter list of the symfun being integrated; if there are no remaining parameters, then the result of the int() is a symbolic expression, but if there is at least one remaining parameter of the original symfun after removing the variable, then the result is a symfun of the remaining variables, in the same order as in the original symfun
Otherwise there is no difference. int() of symfun() proceed by determining the variable to integrate with respect to, stripping the symfun layer off and doing int() of the resulting symbolic expression, and then wrapping the result in a symfun if there are any variables left in the original parameter list.
Using a symfun can certainly be convenient for some uses, saving having to explicitly subs() a value for a variable, but it integrates just like symbolic expressions do with the minor change of how it determines the integration variable if one is not specified
sun on 24 Aug 2021
@Walter Roberson I just noticed that, this polyfit does not work at all. If you check the pic below, you will see, the output of poly does NOT like the orignal temp at all. Do you have any suggestion plz? 