How to write a symfun for given Y values array?

2 vues (au cours des 30 derniers jours)
sun
sun le 19 Août 2021
Commenté : sun le 24 Août 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!

Réponses (1)

Walter Roberson
Walter Roberson le 19 Août 2021
I do not understand your point about needing a symfun?
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
  7 commentaires
Walter Roberson
Walter Roberson le 23 Août 2021
(The function turned out to have a discontinuity inside the integration limits)
sun
sun le 24 Août 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?

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by