2
一个象征性的阵列我有以下代码:乘法数字数组,并在Matlab
a=zeros(1,3);
syms x
y=zeros(1,3);
for j = 1:3
a = [zeros(1,j-1) 1 zeros(1,3-j)];
y(1,j)=x*a(1,j);
display(y(1,j));
end;
,我想给我像[0 x 0]
每个迭代的数组。但是,相反,它给了我以下错误:
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in
Untitled123 (line 6)
y(1,j)=x*a(1,j);
有什么建议吗?
对不起朋友,但是你在上面提供的线索,解决不了我的problem.As我说,我想有一个像[0 X 0]数组,其中x是每次迭代的符号变量,例如,第一次迭代[x 0 0],第二次迭代[0 x 0]和第三次迭代[0 0 x] ... –
@MRMeyqani:是的。这是'y'(你的第三行代码)的分配,而不是'for'循环中的部分。请仔细阅读我的答案。 – horchler
好的,我明白了。 你对循环部分有什么建议吗? –