フィルターのクリア

Why is my array so big?

4 ビュー (過去 30 日間)
David Pesetsky
David Pesetsky 2015 年 2 月 16 日
コメント済み: dpb 2015 年 2 月 18 日
Hello,
I am trying to make a 1 dimensional vertical array of about 5500 strings. Even better, maybe convert the whole thing to a single string using Char()??
Anyway, I need to concatenate several "strings" together, and then store in one array location. But it seems it's not counting the concatenated string as one string, because I got the message the array was too large to be displayed, which shouldn't happen.
The code is too convoluted to post it all, but I believe the relevant pieces are below:
I initialize like this-
AoA = repmat({''}, 5589, 1);
I build up my string in a couple steps. I have a loop that tacks on pieces to this string-
AoAr = [AoAr ',' num2str(mean(AoA_sim(ind)))];
...so I hope that winds up being one long string. Then I tack that onto this-
AoA{k,1} = strcat(num2str(set_theta), ',', ...
num2str(Wr_r_grid(k)*S{NR+2,1}/v_r_grid(k)), ',', AoAr);
...where I again hope the strcat and num2str's force all that to really be just one string that takes up one cell.
Finally I do a-
AoAout=char(AoA);
...and when I try to view AoAout, it says "Cannot display summaries of variables with more than 524288 elements.". So I assume I'm not handling the data properly.
I think it's not smooshing down like I had hoped. I probably went wrong in several areas...can someone help me out?
I appreciate it in advance!
Dave
  10 件のコメント
David Pesetsky
David Pesetsky 2015 年 2 月 17 日
OK, I think you convinced me for numerical accuracy at least to use numbers.
I thought there must be a way to join the mini-strings in your S so that whos would register it as 1x1.
dpb
dpb 2015 年 2 月 17 日
編集済み: dpb 2015 年 2 月 17 日
Well, there is, but you have to look at "the rest of the story"
>> c={s}
c =
'-4, 2.83, 89.65, 81.78'
>> whos c
Name Size Bytes Class Attributes
c 1x1 104 cell
>>
c is a one-cell cell array but it now takes 104 bytes to store the cell string of 22 characters (44 bytes) or 4 doubles (32 bytes). That's even more overhead for the luxury of the cell array.
Cell arrays and cell strings have their place (they're the only way to store "jagged" arrays, for example) but they and the other higher-level datatype abstractions come at a price. "There is no free lunch"

サインインしてコメントする。

採用された回答

David Pesetsky
David Pesetsky 2015 年 2 月 18 日
To close this issue, here's what I've implemented.
I decided to use the "more expensive" cell array, since I have strings mixed with numbers, but it is rectangular.
Initialize-
AoA = zeros( 5590, 50 );
I load up the array with a nested for loop-
AoA{k+1,j} = mean(AoA_sim(ind));
The step that was complaining about "too big to display" I think was doing-
Char(AoA);
...which really isn't needed.
It also exports nicely to xls-
xlswrite('AoA.xls',AoA);
Thanks all, Dave
  1 件のコメント
dpb
dpb 2015 年 2 月 18 日
"...to use the "more expensive" cell array, since I have strings mixed with numbers, ..."
That's another reason for cell arrays, yes...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by