簡體   English   中英

在沒有repmat MATLAB的情況下重復多次向量

[英]repeating a vector many times without repmat MATLAB

我有一個尺寸很大的列格式矢量,我想多次重復此矢量。 適用於小型陣列的簡單方法是repmat但我的內存不足。 我使用了bsxfun但仍然沒有成功,MATLAB給我一個使用ones的內存錯誤。 知道怎么做嗎?

這是簡單的代碼(僅用於演示):

 t=linspace(0,1000,89759)';

 tt=repmat(t,1,length(t));

或使用bsxfun:

 tt=bsxfun(@times,t, ones(length(t),length(t)));

這里的問題僅僅是過多的數據,與repmat函數本身無關。 要驗證是否有太多數據,您可以簡單地嘗試創建一個大小相同且工作空間清晰的矩陣,以重現該錯誤。 在我的系統上,出現以下錯誤:

>> clear
>> a = ones(89759,89759)
Error using ones
Requested 89759x89759 (60.0GB) array exceeds maximum array size preference. Creation of arrays greater than
this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference
panel for more information.

因此,從根本上講,您需要減少要處理的數據量。

另外,我應該注意,繪圖將保留對數據的引用,因此,即使您嘗試“按塊”進行繪圖,仍然會遇到相同的問題。 同樣,您從根本上需要減少要處理的數據量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM