How to find the variable that minimize the root mean squared error between a known vetor and the multiplication of this variable and an another known vector?
7 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
Amal Raj
2023 年 2 月 9 日
Hi 奥 刘,
You can use linear regression to find a.
Please refer this example below:
N = 100; % Example value for N
x = linspace(0, 10, N)'; % Known vector x
y = sin(x) + 0.1 * randn(N, 1); % Known vector y
X = [ones(N, 1) x]; % Design matrix
a = X \ y; % Solve for a using least squares
y_pred = X * a; % Calculate predicted values of y
rmse = sqrt(mean((y - y_pred) .^ 2)); % Calculate RMSE
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Fit Postprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!