Write on unknown cell on Excel
이전 댓글 표시
I have a database on Excel and, using matlab, I want to find the values out of a predefined range. If the values are out of that range I want to replace them with the mean value of them. I've been able to identify the values out of range but I can't replace them with the mean value because I do not exactly know where are the values out of range. I leave a piece of code here:
filename = 'table.xlsx';
sheet = 3;
[table tit]=xlsread(filename,sheet);
phys_carac = table(:,2);
values_hr = table(:,4);
%Set range
hr_max = 140;
hr_min = 60;
hr_table = [];
%calculate mean values. There are more physical characteristics, that's why I calculate first all the means.
for i = 1:length(phys_carac)
if phys_carac(i) == 1
hr = values_hr(i);
hr_table=[hr_table;hr];
mean_hr = round(mean(hr_table));
end
%Find values out of range and replace with mean value
for i = 1:length(phys_carac)
if(values_hr(i) < hr_min) && (values_hr(i) < hr_max)
%here I want to write the mean value
xlwrite(newtable,mean_hr,1,'unknown cell');
end
end
Is there any way to do this? May I choose another way?
Note: I'm using Mac, that's why I use xlwrite (not default matlab function), works as xlswrite.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!