syms i j
b=2*i+3j;
a=zeros(10);
for i=1:10
for j=1:10
a(i,j)=2*b;
end
end
%目的是将循环中计算的值输出到a矩阵中,产生报错如下:
从 sym 转换为 double 时出现以下错误:
错误使用 symengine (line 58)
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
能指出问题吗,感谢

 Respuesta aceptada

0 votos

直接
for i=1:10
    for j=1:10
        a(i,j)=2*(2*i+3*j);
    end
end
否则你前面定义的b,由于不是函数,而是一个等于2*i+3*j的符号式子,不会随着i和j的数值改变尔改变

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!