I am not able to solve this issue?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Jan
am 5 Jun. 2022
@Rakesh Roshan: Your code does not run but produces clear error messages. Simply press the green triangle in the forum's editor to see them.
person_name=T[i,1];
% ^ ^ ???
While the square brackets are wrong here, they are useless in:
age=[T1(i,2)];
[] is the concatenation operator and you concatenate the value ot T1(i,2) with nothing.
You have provided 'count.xlsx', but load 'count.csv'.
Why do you store the value of count in a file?
Please take the time to explain, what exactly the problem with oyur code is. "I have tried out but no luck" is too vague. Did you read the links Image Analyst has provided?
Antworten (1)
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!