Opening XLSX file and setting the variable type to double
Afficher commentaires plus anciens
I am working with .xlsx file and trying to get the values from it and multiply by another value(for tests, I do +1 to every cell, but it is not working as well).
This is the code I am using
Input1 = readtable('OutputFile.xlsx','sheet',2);
WorkData = Input1(17:end,[7,23:end]);
i=[1,14,27,40,53,66,79];
ValueMatrix = table2array(Input1(18:end,23:end));
GWPValues = ValueMatrix(:,i);
GWPValuesMoney = cellfun(@(x) x+1, GWPValues, 'UniformOutput', false);
But when I am trying to add 1 to every cell, it treats the cells as string rather then numeric value.
In ValueMatrix I have only numeric values and NULL

Maybe due to NULL I cannot do mathematical operations with ValueMatrix. If this is the reason how can I substitute all NULLs to 0?
Réponse acceptée
Plus de réponses (1)
Ankit
le 24 Sep 2019
Hello Konstantin,
I have a question why don't you change the excel sheet value from NULL to 0?
Could you please give a try to below code and let me know if its work for you.
Input1 = readtable('OutputFile.xlsx','sheet',2);
WorkData = Input1(17:end,[7,23:end]);
i=[1,14,27,40,53,66,79];
ValueMatrix = table2array(Input1(18:end,23:end));
GWPValues = ValueMatrix(:,i);
tf = strcmp(GWPValues,'NULL');
GWPValues(tf) = {0} ;
GWPValuesMoney = cellfun(@(x) x+1, GWPValues, 'UniformOutput', false);
Thank you
Ankit
1 commentaire
Konstantin Tkachuk
le 27 Sep 2019
Catégories
En savoir plus sur COM Component Integration 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!