Write on unknown cell on Excel
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!