Filter löschen
Filter löschen

I am not able to solve this issue?

15 Ansichten (letzte 30 Tage)
Rakesh Roshan
Rakesh Roshan am 5 Jun. 2022
Kommentiert: Walter Roberson am 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 Kommentare
Jan
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?
Rakesh Roshan
Rakesh Roshan am 11 Jun. 2022
sir i have updated the code now plz tell me how to solve the issue

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
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
Rakesh Roshan
Rakesh Roshan am 12 Jun. 2022
For example in my case ram 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.
Sir...... i dono when i can get error ..it purely depends on interfacing...its unpredictable
program wise error is not there... but sometimes when it gets interfaced at that time only one error comes and it gets stopped.
and that particular time only i have to delete 2nd person detail(suppose it gets stopped here) from csv file and start simulation again from that 2nd person
i hope i have cconveyed it properly.
Walter Roberson
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by