Predicting the value at y(t=8) using my model
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am completeing some LLS analysis and need to predict the value of my model after 8 seconds.
% Problem 3
clc
close all
% Load Data
t = LLS_Data3(:,1);
y = LLS_Data3(:,2);
% Plot the data
figure;
plot(t,y,'.')
% Apply LLS
AL = [t,ones(size(x))]; %
thetaL = inv(AL.'*AL)*(AL.')*y;
yML = thetaL(1)*t + thetaL(2); % Based on equation
% Plot Error over time
figure(1)
errorL = y - yML;
plot(t,errorL, 'x')
xlabel('Time')
ylabel('Error')
hold on
yline(0, 'k')
hold off
This is my current code but am unsure how to use the model to predict my Y value (yML) at t = 8 seconds. The given data set runs for 10 seconds and there are currently 7 values given throughout the 10 second period.
Any help would be appreciated,
Thank you
2 Commenti
Sam Chak
il 29 Mag 2023
Modificato: Sam Chak
il 29 Mag 2023
@Matt Boyles: The given data set runs for 10 seconds and there are currently 7 values given throughout the 10 second period.
Are you suggesting that there are only 7 data points over the entire 10-second period?
Are you looking to predict the output at exactly t = 8 seconds using the LLS model?
Risposte (2)
Sam Chak
il 30 Mag 2023
Hi @Matt Boyles
You can try something like the following to estimate the output. However, there is no guarantee that the estimation at
sec is accurate, as shown in the following example.
subplot(2, 1, 1)
nPts1 = 1001; % number of points
x1 = linspace(0, 10, nPts1);
y1 = sin(4*pi/10*x1) + sin(6*pi/10*x1);
plot(x1, y1, 'linewidth', 1.5), grid on
xlabel('x')
subplot(2, 1, 2)
nPts2 = 7; % number of points
x2 = linspace(0, 10, nPts2);
y2 = sin(4*pi/10*x2) + sin(6*pi/10*x2);
% plot(x2, y2, 'rp')
xlabel('x')
f = fit(x2', y2', 'poly6')
plot(f, x2, y2), grid on
actual_t8 = sin(4*pi/10*8) + sin(6*pi/10*8)
estim_t8 = f(8)
Vedere anche
Categorie
Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
