Predicting the value at y(t=8) using my model
조회 수: 3 (최근 30일)
이전 댓글 표시
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
Sam Chak
2023년 5월 29일
편집: Sam Chak
2023년 5월 29일
@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?
답변 (2개)
Sam Chak
2023년 5월 30일
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)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
