How to write a symfun for given Y values array?

조회 수: 4 (최근 30일)
sun
sun 2021년 8월 19일
댓글: sun 2021년 8월 24일
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!

답변 (1개)

Walter Roberson
Walter Roberson 2021년 8월 19일
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
Walter Roberson
Walter Roberson 2021년 8월 23일
(The function turned out to have a discontinuity inside the integration limits)
sun
sun 2021년 8월 24일
@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?

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by