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
好的,我明白了。 你對循環部分有什麼建議嗎? –