在MATLAB中缓慢的xlsread [英] Slow xlsread in MATLAB

查看:943
本文介绍了在MATLAB中缓慢的xlsread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是MATLAB程序仿真运行的结果。

Here is the result of a profiled simulation run of my MATLAB program. I need to run this simulation several hundred thousand times (~100,000 times).

因此,我需要一个更快的方式来阅读Excel文件。

Thus I need a faster way to read the Excel file.

规格:Excel文件为10000x2个单元格,每个模拟运行都是从5个单独的Excel文件中读取一张此类表单。

Specifications: The Excel file is of 10000x2 cells and each simulation run is reading one such sheet each from 5 separate Excel files.

更新:我将xlsread置于基本模式,并通过将输入组合到一个文件中来减少呼叫次数。下一个目标是xlswrite。啊,那下沉的感觉:|

UPDATE: I put the xlsread in basic mode and also reduced the number of calls by combining my input into a single file. Next target is xlswrite now. Ah, that sinking feeling. :|

注意:虽然写入 CSV 文件使用dlmread非常快(大约20次),我需要使用.xls文件提供的单独的工作表。

NOTE: Although writing to a CSV file using dlmread is very fast (around 20 times), I need to use the comfort of separate sheets that an .xls file provides.

推荐答案

如果您需要 Excel表格作为输出,我认为您无法从xlswrite中获取更多收益。

I don't think you would be able to wring much out of xlswrite if you need Excel sheets as the output.

如何并行化?

您是否可以访问并行计算工具箱?或者你可以运行两个MATLAB实例,如果你的框支持它。如果是,您可以考虑两种方法:

Do you have access to the parallel computing toolbox? Or maybe you can run two instances of MATLAB if your box supports it. If so, you could consider two approaches:


  1. 让第一个进程执行xlsread部分,模拟部分然后写入垫文件/纯二进制/ CSV,无论是最快的还是保持数据完整性。有另一个进程使用xlswrite将matfiles /中间数据文件转换成Excel。

  1. Have the first process do the xlsread part, the simulation part and then write to mat files/plain binary/CSV, whatever is the fastest while preserving your data integrity. Have another process convert the matfiles/intermediate data files into Excel using xlswrite.

有N个MATLAB实例/工作人员(N取决于您的物理机容量)。将N个工作人员的整个读取过程写入部分并行化。注意,我不知道Excel工作人员调用时Excel会如何缩放! (xlswrite使用activeX / MS Excel写入数据)。

Have N MATLAB instances/workers (N depends on your physical machine capacity). Parallelize the whole read-process-write part across N workers. Note, I am not sure how Excel would scale when called by N workers! (xlswrite uses activeX/MS Excel to write the data).

如果使用任何并行方法,您的里程将会有所不同模拟的复杂性与所需的文件I / O及其性能。

As any parallel approach, your mileage will vary on the complexity of the simulation vs. required file I/O and its performance.

这篇关于在MATLAB中缓慢的xlsread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆