I need an efficient way to color Excel cells based on value using Matlab activeX control
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I currently process many hundreds of files each with about 24,000 data points. The processed results are then delivered to another team that does not use Matlab so instead an Excel spreadsheet is used. They have an automated tool that reads the sheet so I must output Excel. I have found that I can write the data to Excel very fast using these commands
[nr, nc] = size(array.(fn{i}).minrat');
c1 = get(AS.Cells, 'item', 2, hend + 1);
c2 = get(AS.Cells, 'item', 2 + nr - 1, hend + 1 + nc - 1);
range = get(AS, 'range', c1, c2);
vals = arrayfun(@(x) sprintf('%4.2f',x), array.(fn{i}).minrat, ...
'UniformOutput', 0);
set(range, 'Value', vals');
Applying the colors is much more painful.
color = array.(fn{i}).color';
for j = 1:nr
for k = 1:nc
c1 = get(AS.Cells, 'item', 1 + j, hend + k);
c1.Interior.ColorIndex = color(j, k);
end
end
I have used the profiler to show me where all my time is. For a run that took 272 seconds, 266 seconds where that inner loop. Previously the entire Matlab data was written out in the loop and finding the set range value was huge. Is there something I can do similar to that for colors?
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!