フィルターのクリア

For loop update matrix

1 回表示 (過去 30 日間)
Victor
Victor 2014 年 6 月 6 日
コメント済み: Star Strider 2014 年 6 月 6 日
In my for loop i want to create and append the elements in a column vector everytime i run the function.

採用された回答

Star Strider
Star Strider 2014 年 6 月 6 日
From my previous Answer to your similar question:
for k2 = 1:2 % Simulate two function calls
a = 30; % Input argument
b = 400; % Input argument
k1i = 0; % First line of actual function
filex = 0; % File doesn’t exist at first
filename = 'input_data_file.mat';
if exist(filename,'file') % If file exists, load it
load(filename)
k1i = mtrx(end,1); % Find previous end index value
filex = 1;
end
for k1 = k1i+1:(k1i+a) % Loop to create this version of ‘mtrx’
mtrx(k1,:) = [k1 b];
end
if filex == 1 % If file exists, append to it, if not create it
save(filename, 'mtrx', '-append')
elseif filex == 0
save(filename, 'mtrx')
end % Last line of function (other than its own ‘end’ statement)
fout = fopen('input_data_textfile.txt', 'w+');
fprintf(fout, '%d ', mtrx') % Write text file
end
  6 件のコメント
Victor
Victor 2014 年 6 月 6 日
For those plots, how do i control the spacing if i were to use the subplot function?
Star Strider
Star Strider 2014 年 6 月 6 日
I saw your Question on that and submitted an Answer. It has been the subject of several recent posts here, so I referred you to the best of those. There are also several topics in the Examples section of the documentation page for subplot.
The idea is to use the 'Position' property in each subplot and adjust it individually for each subplot.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by