【发布时间】:2023-01-02 16:34:56
【问题描述】:
我是朱莉娅的新手。在那之前,我使用 Matlab。 对于 Matlab 的情况,我写了命令在 for 循环中制作矩阵,如下所示:
for i=1:1:100; k(i,:)=i.^2; end
我在 Julia 中输入了相同的命令,但没有用。 此外,我尝试了如下其他命令:
n=100;
k = Array(Int64, n);
for i in 1:n;
k[i]= i;
end;
但是,错误发生如下:
MethodError: no method matching setindex!(::Type{Array{Int64, 10}}, ::Int64, ::Int64)
如何在 Julia 的 for 循环中创建矩阵?
【问题讨论】: