フィルターのクリア

how to save the matrix after each iteration ?

26 ビュー (過去 30 日間)
riki ragùa
riki ragùa 2018 年 3 月 14 日
コメント済み: Geoff Hayes 2020 年 4 月 14 日
I have a for loop from 1 to 768 in each iteration I will discard one old sample and add new one (the procedùre is like a convolùtion). the oùtpùt for each iteration is a matrix of dimention [384 1] I want to plot this matrix when adding new sample.
  2 件のコメント
Geoff Hayes
Geoff Hayes 2018 年 3 月 14 日
riki - is the output of each iteration always of the same (384x1) dimension? If so, then you could create a matrix that will hold each of the 768 matrices (could be simply 384x768 where each column is the output from each iteration). If the output of each iteration is of a different dimension, then consider using a cell array to store the data.
riki ragùa
riki ragùa 2018 年 3 月 15 日
yes, the output matrix will always be of same dimention how can I hold the matrices ?

サインインしてコメントする。

回答 (2 件)

Pawel Jastrzebski
Pawel Jastrzebski 2018 年 3 月 15 日
output = 384;
iterations = 768;
% preallocate the matrix
mResults = zeros(output, iterations);
for i = 1:iterations
% your code, i.e.:
mResults(:,i) = rand(output,1);
end
  1 件のコメント
riki ragùa
riki ragùa 2018 年 3 月 15 日
thank you

サインインしてコメントする。


Geoff Hayes
Geoff Hayes 2018 年 3 月 15 日
riki - since your output array on each iteration is of the same dimension, then your matrix could be
myData = zeros(384,768);
and when iterating, you could do something like
for k=1:768
% do a calculation to get the output
output = ...;
% save this to your myData matrix
myData(:,k) = output; % since output is 384x1 matrix
end
  4 件のコメント
Aashish Jagadeesh Shastry
Aashish Jagadeesh Shastry 2020 年 4 月 14 日
If the output has dimensions like (2,13) and the number of iterations is 2, how can I save the matrix for each iteration?
Geoff Hayes
Geoff Hayes 2020 年 4 月 14 日
Aashish - you could assign something like
myData = zeros(2,13);
for k=1:2
% do a calculation to get the output
output = ...;
% save this to your myData matrix
myData(k,:) = output; % since output is 2x13 matrix
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by