ode45 say that return column vector using lsqcurvefit
이전 댓글 표시
I made 'lsqcurvefit optimization'. The file name is 'sample'. It works well.
And ' (a1 * 2 * f1 * pi * cos(2 * f1 * pi * t))' this formula is about velocity.
function FF = BF(t, a)
a1 = 5;
f1 = 0.5;
n = 1;
g = @(t, x)[(a1 * 2 * f1 * pi * cos(2 * f1 * pi * t));
-abs(a1 * 2 * f1 * pi * cos(2 * f1 * pi * t))*a(6)*x(2)*abs(x(2))^(n-1)-a(5)*a1 * 2 * f1 * pi *
cos(2 * f1 * pi * t)*abs(x(2))^n+a(4)*a1 * 2 * f1 * pi * cos(2 * f1 * pi * t)];
[t, xa] = ode45(@(t,x) g(t, x), t, [0 0]);
u = a1 * 2 * f1 * pi * cos(2 * f1 * pi * t);
FF = a(1)*u(:,1)+a(2)*xa(:,1)+a(3)*xa(:,2);
end
But I got velocity data by a experiment. So i substituted that formula to 'experiment data'.
The file name is sample_2.
I changed something.
First, i removed 'this (a1 * 2 * f1 * pi * cos(2 * f1 * pi * t))'. and i put 'velocity1 [9000x1 vector]'.
Second, i put 'velocity1_int' transposed for making [1x9000 vector].
But, it says '@(X,T)G(X,T) must return a column vector.'
Could you help me about this...
function FF = BF(velocity1, a, dk1)
n = 1;
t = (0:0.0006:5.3994)';
velocity1_int = velocity1';
g = @(x,t) [(-abs(velocity1_int)*a(4)*x(1)*abs(x(1))^(n-1)...
-a(5)*velocity1_int*abs(x(1))^n+a(6)*velocity1_int)];
[xa] = ode45(@(x,t) g(x,t), t, [0]);
FF = a(1)*velocity1+a(2)*dk1+a(3)*xa;
end
채택된 답변
추가 답변 (1개)
madhan ravi
2018년 11월 11일
g = @(x,t) [(-abs(velocity1_int)*a(4)*x(1)*abs(x(1))^(n-1);
-a(5)*velocity1_int*abs(x(1))^n+a(6)*velocity1_int)];
댓글 수: 1
CHOI HYUNDUK
2018년 11월 11일
편집: CHOI HYUNDUK
2018년 11월 11일
카테고리
도움말 센터 및 File Exchange에서 Matrix Computations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!