How to tune matrices to specific output?
2 次查看(过去 30 天)
显示 更早的评论
Hey guys. So I have four matrices that are each 8 by 8: matrix P, matrix Q, matrix R, and matrix G. I have a certain algorithm (I wont go in to too much details about it because its too complicated with multiple files) that depends on those four matrices and uses them to output a single column of values for me. I also have what I call the perfect output, which is what I desire the output single column to look like. Now my question is: How can I use MATLAB to tune those 4 matrices in order for the output column to match the perfect output column?
8 个评论
Sam Chak
2023-9-26
The code is looking good. 👍
% Initialize P, Q, R, G
P = [0.5 2.5; 3.5 1.5];
Q = P;
R = Q;
G = R;
perfectoutput = [1; 81; 256; 16];
x0 = cat(3, P, Q, R, G);
lsqnonlin(@(x) computeOutput(x(:,:,1), x(:,:,2), x(:,:,3), x(:,:,4)) - perfectoutput, x0)
function output = computeOutput(P, Q, R, G)
M = P.*Q.*R.*G;
output = [M(1); M(2); M(3); M(4)];
end
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biological and Health Sciences 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!