So I have this set of data, it's humidity vs time when drying food. I need the speed of drying so what do I do? I use cftool to find best fit of data then I tag the fit and export to workspace.
I have:
time=[1;2;3;4;5;6] x=[0.5;0.4;0.3;0.25;0.22;0.18]
I use cftool to fit it and export to worskpace
Then i use;
Rc=diff(finame(time))
Rc stands for speed in water removal (drying) and it gives back a vector with only 5 numbers, when it should give me a vector with 6 elements, each one the result of the derivate for each time...yet, as i said it doesn't... why is this?
Thanks a lot for the answers.

 채택된 답변

Sean de Wolski
Sean de Wolski 2013년 10월 4일
편집: Sean de Wolski 2013년 10월 4일

0 개 추천

From the doc for diff
If X is a vector of length m, then Y = diff(X) returns a vector of length m-1. The elements of Y are the differences between adjacent elements of X.
Y = [X(2)-X(1) X(3)-X(2) ... X(m)-X(m-1)]
Thus it does the backward differences requiring one element shorter. IF you want the vector to be the same length, pad it with a 0.
There's also this file that might interest you:

댓글 수: 3

Thomas
Thomas 2013년 10월 4일
do not pad with a 0, this would alter your result. Rather pad 0.6 at the front or 0.14 at the end.
Juan Carlos
Juan Carlos 2013년 10월 4일
Thanks! :)
Sean de Wolski
Sean de Wolski 2013년 10월 4일
@Thomas, padding the results with a zero would not alter the results, just shift them.

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

추가 답변 (1개)

Thomas
Thomas 2013년 10월 4일

0 개 추천

It cannot give 6 elements since it calculates differences between successive elements and for 6 input values there are only differences e.g. assuming time=1:6 you have
INPUT : x=[ a b c d e f] (count 6) OUTPUT: differences used are b-a, c-b, d-c, e-d, f-e (count 5)
If you really need 6 values you could extrapolate your data boundaries and use a central differencing scheme.

댓글 수: 1

Juan Carlos
Juan Carlos 2013년 10월 4일
Yes! I thought i was something like that, i'll extrapolate. THANKS!

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

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

2013년 10월 4일

댓글:

2013년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by