我有一个名为A的矩阵。例如以下内容:
A = [1 2 3; 3 4 1; 2 4 4]
现在我有以下等式: A(x,y)=(j ^ x)*(i ^ y)
j和i是正常值(维度1x1),而不是矩阵的索引。 ^
让我们举个例子:
A(1,1) = 1 (First value of the Matrix)
1 = (j^1)*(i^1)
还有第二个:
A(1,2) = 3
3 = (j^1)*(i^2)
是否有可能使用Matlab接收两个参数的解决方案?
答案 0 :(得分:2)
以下是一些可以找到问题的最佳解决方案的代码(如果有的话)。在这种情况下,没有合理的解决方案,但通过A
定义M([4 2])
(例如)确实运行得相当好。
A = [1 2 3; 3 4 1; 2 4 4] %// the A matrix
[C,R]=meshgrid(1:3) %// create matrices of row/column indices
M=@(xy) xy(2).^C.*xy(1).^R %// calculates matrix of elements j^x*i^y
d=@(xy) A-M(xy) %// calculates difference between A and the calculated i^x*y^j matrix
r=fsolve(@(xy) norm(d(xy)),[1 1]) %// use fsolve to attempt to find a solution
d(r) %// show resulting difference between target matrix and solution matrix
norm(d(r)) %// norm of that matrix
M(r) %// show the solution matrix