Hi all, This code is meant to take user input, and store it onto a text file, however when n > 1 in my code, it will only store the last user input into the array, and replace all the previous values (of y,x,z) inputed with 0. How can this be resolved? Here is my code:
fid1 = fopen('set_p.txt','w');prompt2 = 'How many data sets do you want to take?\n';n = input(prompt2);p = n-1;clearvars x y z;for j = 1:n prompt3 = 'How long do you want the test to run (s)?\n'; y(n) = input(prompt3); prompt4 = 'What sampling interval do you want to have (s)?\n'; x(n) = input(prompt4); if p == 0 z = 0; elseif j <= p prompt5 = 'How long do you want between each data set (s)?\n'; z(p) = input(prompt5); endendfprintf(fid1, '%6.3f,',n,y,x,z);fclose(fid1);
Thanks for all the help in advance!
Best Answer