recall Equation of fit curve and integrate
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have set the curve fitting and know that "formula" finds me the equation of the line. I cant seem to figure out a way to jsut automatically set it equal to a variable without manually typing "formula(linefit)" and pasting the actual equation into my code. I tried "accelformula= formula(linefit)" which works, but the moemnt I try "vformula=int(accelformula)" mat lab give me an error.
clc
clear all
close all
figure(1)
accel1=readtable('accelplot1','PreserveVariableNames',true);
a=1550;
b=1850;
time=accel1{a:b,1};
ay=accel1{a:b,7};
%xlim([8.75 11.25])
linefit=fit(time,ay,'sin2');
%plot(linefit,time,ay)
yfitted = feval(linefit,time);
subplot(2,2,1)
plot(time,ay,'b',time,yfitted,'r')
title('Accelorometer data')
xlabel('time(sec)')
ylabel('acceleration(in/sec^2')
%% acceleration to displacement
a1=linefit.a1;
b1=linefit.b1;
c1=linefit.c1;
a2=linefit.a2;
b2=linefit.b2;
c2=linefit.c2;
syms x
accelformula= formula(linefit)
velformula=int(a1*sin(b1*x+c1) + a2*sin(b2*x+c2))
vformula=int(accelformula)
subplot(2,2,2)
w=min(time):max(time)
fplot(velformula,w)
title('Velocity')
xlabel('time(sec)')
ylabel('Velocity(in/sec)')
0 comentarios
Respuestas (1)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!