There is a loop;
for i = 1:n
X_rotate = X.*cos(i*increment) - Y.*sin(i*increment);
X_rotateh = X_rotate./cos(deg2rad(helix_angle));
Y_rotate = X.*sin(i*increment) + Y.*cos(i*increment);
Helix = [X_rotateh(1:K1) ; Y_rotate(1:K1)];
fileID = fopen('helix_values.txt', 'w');
fprintf(fileID,'%f %f\n ', Helix);
fclose(fileID);
end
X and Y are row vectors and their size depends on inputs. By the way, the iteration number n and the size of X and Y can be different. As I said, they depend on inputs.
When open the text file, there just exists the values of last iteration for X_rotateh and Y_rotate. I need to collect the values of X_rotateh and Y_rotate from first value to K1 th value of both for every iteration. I have tried to use cat command. It did not give what I want. On the other hand, I usually meet problems which are about length or size of arrays.
Those values should be in order in text file like;
%for first iteration;
X_rotateh(1) Y_rotate(1)
X_rotateh(2) Y_rotate(2)
.
.
X_rotateh(K1) Y_rotate(K1)
%for second iteration;
X_rotateh(1) Y_rotate(1)
X_rotateh(2) Y_rotate(2)
.
.
X_rotateh(K1) Y_rotate(K1)
%so on..
What may I do ?
Thanks in advance.
fileID = fopen('helix_values.txt', 'a')to append data to the file. Also, thatfopenline probably shouldn't be in the loop'a'for append, not'w'from write which actually overwrites the file.fcloseout of the loop! open the file, the loop and append to it, then close the file.