[英]Filling the rows of a matrix with vectors in MATLAB
假設我正在使用計算3維向量的函數“ fun”。 我想要的是使用for循環創建具有向量“ fun”的矩陣,每次將其作為行進行計算。
謝謝,尼科斯
這取決於您要運行“ fun”功能多少次? 我們稱其為“ n”。
% if you know the number of times you are going to run 'fun' you can initialize the final
matrix to be output = zeros(n,3);
n = 5;
output = zeros(n,3);
for i=1:n
output(i,:) = fun(); % and you have to give whatever parameters 'fun' takes here
end
我不確定這是否能完全回答您的問題,但足以讓您入門。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.