Azzera filtri
Azzera filtri

For loop update matrix

1 visualizzazione (ultimi 30 giorni)
Victor
Victor il 6 Giu 2014
Commentato: Star Strider il 6 Giu 2014
In my for loop i want to create and append the elements in a column vector everytime i run the function.

Risposta accettata

Star Strider
Star Strider il 6 Giu 2014
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 Commenti
Victor
Victor il 6 Giu 2014
For those plots, how do i control the spacing if i were to use the subplot function?
Star Strider
Star Strider il 6 Giu 2014
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by