ode45 say that return column vector using lsqcurvefit
Show older comments
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
Accepted Answer
More Answers (1)
madhan ravi
on 11 Nov 2018
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 Comment
CHOI HYUNDUK
on 11 Nov 2018
Edited: CHOI HYUNDUK
on 11 Nov 2018
Categories
Find more on Matrix Computations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!