I am not able to solve this issue?
54 views (last 30 days)
Show older comments
no_of_people=4;
T = readtable('88.xlsx');
T1=table2cell(T);
for i=1:4 %no of people
count=csvread('count.csv') %extracting the data
person_name=[T{i,1}];
age=[T1(i,2)];
indicate=[T1(i,3)];
BP1=[T1(i,4)];
BP2=[T1(i,5)];
BP3=[T1(i,6)]
BloodPressure=BP3+50;
total=[person_name age indicate BP1 BP2 BloodPressure]
dlmwrite('input.csv',total,'-append','delimiter',',')
count=count+1;
if count<=no_of_people
dlmwrite('count.csv',count);
else count=1
dlmwrite('count.csv',count)
end
end
For each person 3 simulations are carried out. If by chance in 2nd simulation it gets stopped, then data from 2nd simulation entirely should get deleted and start from that simulation only.
For example in my case sanchez will be selected first 1 simulation perfectly performed data is written into input.csv then in 2nd simulation it is stopped. Data written is entirely deleted and simulation starts from that 2nd simulation. I have tried out but no luck
I'm using the 2018a version.
4 Comments
Answers (1)
Walter Roberson
on 11 Jun 2022
csvread() can never read text. It could be configured to skip the first column, but your code wants that information.
You should use readtable() with ReadVariableName set false.
4 Comments
Walter Roberson
on 12 Jun 2022
main_output_name = 'my_results.txt';
backup_name = 'backup_copy.txt';
fid = fopen(main_output_name, 'w'); fclose(fid);
copyfile(main_output_file, backup_name);
for K = 1 : 4
try
attempt step #K
determine whether step worked, contents look wrong somehow
if it_worked
copyfile(main_output_file, backup_name); %becomes permanent
else
copyfile(backup_name, main_output_file); %remove output
end
catch ME
%problem such as subscript
copyfile(backup_name, main_output_file); %remove output
end
end
This is what I told you to do before, just explicitly showing try/catch
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!