How to export "Nan" and "inf" in a table from MATLAB to EXCEL as text?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I created a code that generates a table "R" that has a column called "number" which has values including inf and NaN. I'm exporting this table into EXCEL. However, NaN shows as blank cell and inf shows as 65535. Is it possible to convert Nan and inf as text to EXCEL?
I was trying to add a for loop that checks for any inf and NaN in table and convert them to a string but I'm not able to do it correctly. Here is my attempt:
for y=1:10
R.number(isinf(R.number))= ;
R.number(isnan(R.number))= ;
end
writetable(R,'r.xlsx','Sheet',1);
Any help is appreciated!
0 commentaires
Réponse acceptée
Walter Roberson
le 15 Mar 2023
base = tempname;
cname = base + ".csv";
xname = base + ".xlsx";
A = [1; 2; 3; nan; inf];
writematrix(A, cname)
dbtype(cname)
B = readcell(cname)
writematrix(A, xname)
C = readcell(xname)
masknan = isnan(A);
maskinf = A == inf;
D = num2cell(A);
D(masknan) = {'NaN'};
D(maskinf) = {'Inf'};
writecell(D, xname)
E = readcell(xname)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!