小编Nic*_*k_R的帖子

这个MATLAB代码有什么问题?

我想在MATLAB中做以下,

global a b c d e f g h l;
A=[1 3;3 2];
B=[a 0;0 b];
C=[d 0;e f];
Ctranspose=transpose(C);
D=[sqrt(d) 0;0 sqrt(f)];
E=Ctranspose/D;
Etranspose=transpose(E);
K=A+E;
M=E*D*Etranspose;

for a=1:10
  for b=1:10
    if  K==M
      print(a);
      print(b);
      print(d);
      print(e);
      print(f);
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

一个)

Error using  + 
Matrix dimensions must agree.

Error in trial (line 6)
K=A+B
Run Code Online (Sandbox Code Playgroud)

b)

Error using vertcat
CAT arguments dimensions are not consistent.

Error in trial (line 5)
C=[d 0;e f];
Run Code Online (Sandbox Code Playgroud)

这有什么不对?

(请注意,我是MATLAB的新手)

谢谢

matlab concatenation dimensions

3
推荐指数
1
解决办法
814
查看次数

如何以编程方式删除Excel工作表VB.NET

我试图从excel工作簿中永久删除工作表,但它没有按预期工作,

CType(oWB1.Sheets("ABC"), Excel.Worksheet).Delete()
Run Code Online (Sandbox Code Playgroud)

这有什么不对?

vb.net excel worksheet

2
推荐指数
1
解决办法
2万
查看次数

MATLAB代码不起作用(梯度下降算法)

我正在尝试渐变血统,但我写了以下但没有得到任何答案,

n=0;            %initialize iteration counter 
eps=1;          %initialize error 
a=0.8;         %set iteration parameter 
x=[1;1];        %set starting value
f=6*x(1)^2+8*x(2)^2-3*x(1)*x(2);
%Computation loop 
while eps>1e-12||n<100 
   gradf=[12*x(1)-3*x(2); 16*x(2)-3*x(1)];  %gradf(x) 
   eps=(norm(gradf)/(1+abs(f)));                                %error 
   y=x-a*gradf;                                                 %iterate 
   x=y;                                                         %update x 
   n=n+1;                                                       %counter+1 
end 
n;x;eps;        %display end values
Run Code Online (Sandbox Code Playgroud)

当我将此文件添加到路径并键入x时,它显示NaN,NaN.怎么了?

algorithm matlab

1
推荐指数
1
解决办法
6268
查看次数