如何在Matlab中创建一维数组? [英] How to create single dimensional array in matlab?
本文介绍了如何在Matlab中创建一维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在MATLAB中的for循环中创建一维数组,请提供以下代码的帮助:
i want to create a single dimensional array in MATLAB inside for loop, please help with below code:
count = 0;
for i=1:10
arr = count;
count = count+1;
end
当我执行这个小代码时,我得到9作为arr的结果.
when i execute this small code i got 9 as result for arr.
相反,我想为数组i的每次迭代提供10个计数值的数组arr,请帮忙.....
Instead of this i want to have an array arr with 10 values of count for each iteration of i, please help.....
推荐答案
arr = zeros(10,1); % to initialize array
count = 0;
for i=1:10
arr(i) = count;
count = count+1;
end
这篇关于如何在Matlab中创建一维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文