MatLab memory allocation when max size is unknown

后端 未结 3 447
不知归路
不知归路 2021-01-14 04:34

I am trying to speed up a script that I have written in Matlab that dynamically allocates memory to a matrix (basicallly reads a line of data from a file and writes it into

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 05:33

    If you want to stick to your code as written I would substitute your initialization of data, data = [] to

    data = zeros(1,1000); 
    

    Keep in mind though the warning from @MZimmerman6: zeros(1000) generates a 1000 x 1000 array. You may want to change all of your zeros statements to zeros( ... ,Nc), where Nc = length of line in characters.

提交回复
热议问题