I am not able to solve this issue?

39 views (last 30 days)
Rakesh Roshan
Rakesh Roshan on 5 Jun 2022
Commented: Walter Roberson on 12 Jun 2022
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
Error using dlmread
Unable to parse a "Numeric" field when reading row 1, field 1.
Actual Text: "Sanchez,38,1,71,176,124"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive)

Error in csvread (line 53)
m=dlmread(filename, ',', r, c); %#ok<*DLMRD>
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
Rakesh Roshan
Rakesh Roshan on 11 Jun 2022
sir i have updated the code now plz tell me how to solve the issue

Sign in to comment.

Answers (1)

Walter Roberson
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
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

Sign in to comment.

Categories

Find more on File Compression in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!