Predicting the value at y(t=8) using my model
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
@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?
Matt Boyles
il 29 Mag 2023
Risposte (2)
thetaL(1)*8 + thetaL(2)
2 Commenti
Matt Boyles
il 29 Mag 2023
Torsten
il 29 Mag 2023
If you have a function yM7(t) and you want to find its value at t=8, how do you do that ? You insert 8 for t, don't you ?
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)
1 Commento
Matt Boyles
il 31 Mag 2023
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
